Skip to content

Commit

Permalink
MDL-36506 mod_book: Skip legacy files migration if missing a CM record
Browse files Browse the repository at this point in the history
  • Loading branch information
tlock committed Mar 24, 2015
1 parent 7e39143 commit 9ad24a0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mod/book/db/upgradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,16 @@ function mod_book_migrate_moddata_dir_to_legacy($book, $context, $path) {
* @return void
*/
function mod_book_migrate_all_areas() {
global $DB;
global $DB, $OUTPUT;

$rsbooks = $DB->get_recordset('book');
foreach($rsbooks as $book) {
upgrade_set_timeout(360); // set up timeout, may also abort execution
$cm = get_coursemodule_from_instance('book', $book->id);
if (empty($cm) || empty($cm->id)) {
echo $OUTPUT->notification("Course module not found, skipping: {$book->name}");
continue;
}
$context = context_module::instance($cm->id);
mod_book_migrate_area($book, 'intro', 'book', $book->course, $context, 'mod_book', 'intro', 0);

Expand Down

0 comments on commit 9ad24a0

Please sign in to comment.