File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -349,5 +349,25 @@ function xmldb_cms_upgrade($oldversion) {
349
349
upgrade_mod_savepoint (true , 2024090301 , 'cms ' );
350
350
}
351
351
352
+ if ($ oldversion < 2023120102 ) {
353
+ $ dbman = $ DB ->get_manager ();
354
+ // Conditionally launch add field valuetrust.
355
+ if ($ dbman ->field_exists ('customfield_data ' , 'valuetrust ' )) {
356
+ $ sql = "SELECT mcd.id mcdid
357
+ FROM {customfield_data} mcd
358
+ JOIN {customfield_field} mcf ON mcf.id = mcd.fieldid
359
+ JOIN {customfield_category} mcc ON mcc.id = mcf.categoryid
360
+ WHERE mcc.component = 'mod_cms' AND mcd.valuetrust = 0 " ;
361
+ $ records = $ DB ->get_records_sql ($ sql );
362
+ $ mcdids = array_keys ($ records );
363
+ foreach (array_chunk ($ mcdids , 100 ) as $ ids ) {
364
+ [$ sql , $ params ] = $ DB ->get_in_or_equal ($ ids );
365
+ $ sql = 'UPDATE {customfield_data} SET valuetrust = 1 WHERE id ' . $ sql ;
366
+ $ DB ->execute ($ sql , $ params );
367
+ }
368
+ }
369
+ upgrade_mod_savepoint (true , 2023120102 , 'cms ' );
370
+ }
371
+
352
372
return true ;
353
373
}
You can’t perform that action at this time.
0 commit comments