@@ -413,49 +413,5 @@ function xmldb_cms_upgrade($oldversion) {
413
413
upgrade_mod_savepoint (true , 2024090303 , 'cms ' );
414
414
}
415
415
416
- if ($ oldversion < 2024090304 ) {
417
- // Update files belonging to mod_cms overview section content types to use the course module context id.
418
- // Update the pathnamehash as well, otherwise files will display as missing until the content is edited and saved.
419
- // Records are effectively copied, the old records remain in case anything relies on them and they can be used to
420
- // cross reference the new records if needed.
421
-
422
- $ sql = "SELECT f.*, ctx.id as ctxid
423
- FROM {files} f
424
- JOIN {customfield_data} cfd ON cfd.id = f.itemid
425
- JOIN {customfield_field} cff ON cff.id = cfd.fieldid AND cff.shortname = 'overview'
426
- JOIN {cms} cms ON cms.id = cfd.instanceid
427
- JOIN {course_modules} cm ON cm.instance = cms.id
428
- JOIN {modules} m ON m.id = cm.module AND m.name = 'cms'
429
- JOIN {context} ctx ON ctx.instanceid = cm.id AND ctx.contextlevel = 70
430
- WHERE f.contextid = 1 AND f.component = 'customfield_textarea' AND f.filearea = 'value' " ;
431
-
432
- $ records = $ DB ->get_recordset_sql ($ sql );
433
- foreach ($ records as $ record ) {
434
- // Update the record with the new context id and path name hash.
435
- $ record ->contextid = $ record ->ctxid ;
436
- $ record ->pathnamehash = file_storage::get_pathname_hash (
437
- $ record ->contextid ,
438
- $ record ->component ,
439
- $ record ->filearea ,
440
- $ record ->itemid ,
441
- $ record ->filepath ,
442
- $ record ->filename
443
- );
444
-
445
- // Remove the record id and ctxid fields.
446
- unset($ record ->ctxid );
447
- unset($ record ->id );
448
-
449
- // Create a new record.
450
- try {
451
- $ DB ->insert_record ('files ' , $ record );
452
- } catch (moodle_exception $ e ) {
453
- debugging ('Failed to insert record into files table: ' . $ e ->getMessage (), DEBUG_DEVELOPER );
454
- }
455
- }
456
-
457
- upgrade_mod_savepoint (true , 2024090304 , 'cms ' );
458
- }
459
-
460
416
return true ;
461
417
}
0 commit comments