mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-36506 mod_book: Skip legacy files migration if missing a CM record
This commit is contained in:
parent
c1f4001bd1
commit
2a3e6f87da
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user