diff --git a/question/bank/columnsortorder/db/upgrade.php b/question/bank/columnsortorder/db/upgrade.php index 0228fc9813f..db40361f8ec 100644 --- a/question/bank/columnsortorder/db/upgrade.php +++ b/question/bank/columnsortorder/db/upgrade.php @@ -82,11 +82,9 @@ function xmldb_qbank_columnsortorder_upgrade(int $oldversion): bool { // 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, 2024042203, 'qbank', 'columnsortorder'); }