MDL-82335 qbank_columnsortorder: Cleanup upgrade code

This commit is contained in:
Huong Nguyen 2024-11-07 13:35:01 +07:00
parent a25399959c
commit c89b3279bb
No known key found for this signature in database
GPG Key ID: 40D88AB693A3E72A

View File

@ -77,22 +77,20 @@ function xmldb_qbank_columnsortorder_upgrade(int $oldversion): bool {
upgrade_plugin_savepoint(true, 2024051000, 'qbank', 'columnsortorder');
}
// Automatically generated Moodle v4.5.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2024100701) {
// When upgrading to version 2024042201, if there were any values for colsize in qbank_columnsortorder plugin,
// they were getting incorrectly updated, resulting in corrupted colsize value,
// e.g., '"width":"30"}-"width":"30"},"width":"180"}-"width":"180"} and thus breaking the question bank page.
$pluginconfig = $DB->get_record('config_plugins', ['plugin' => 'qbank_columnsortorder', 'name' => 'colsize']);
if ($pluginconfig) {
$pattern = '/"width":"[^"]*"}-"width":"[^"]*"}/';
if (preg_match($pattern, $pluginconfig->value)) {
$DB->delete_records('config_plugins', ['plugin' => 'qbank_columnsortorder', 'name' => 'colsize']);
}
$pattern = '/"width":"[^"]*"}-"width":"[^"]*"}/';
if ($pluginconfig && preg_match($pattern, $pluginconfig->value)) {
$DB->delete_records('config_plugins', ['plugin' => 'qbank_columnsortorder', 'name' => 'colsize']);
}
upgrade_plugin_savepoint(true, 2024100701, 'qbank', 'columnsortorder');
}
// Automatically generated Moodle v4.5.0 release upgrade line.
// Put any upgrade step following this.
return true;
}