mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 05:54:19 +02:00
MDL-82335 qbank_columnsortorder: Fix upgrading issue
When upgraded to Moodle 4.4 or higher, for qbank_columnsortorder the colsize values in the config_plugins were getting incorrectly set, resulting in errors accessing the question bank. Changes done to fix this code and to remove the corrupted colsize value from config_plugins table.
This commit is contained in:
parent
d015c4c213
commit
795fa07c3c
@ -42,7 +42,7 @@ function xmldb_qbank_columnsortorder_upgrade(int $oldversion): bool {
|
||||
$pluginconfigs = $DB->get_records('config_plugins', ['plugin' => 'qbank_columnsortorder'], 'name');
|
||||
|
||||
foreach ($pluginconfigs as $config) {
|
||||
if ($config->name == 'version') {
|
||||
if (!in_array($config->name, ['hiddencols', 'enabledcol', 'disabledcol'])) {
|
||||
continue;
|
||||
}
|
||||
$fields = explode(',', $config->value);
|
||||
@ -77,6 +77,20 @@ function xmldb_qbank_columnsortorder_upgrade(int $oldversion): bool {
|
||||
upgrade_plugin_savepoint(true, 2024051000, 'qbank', 'columnsortorder');
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
}
|
||||
upgrade_plugin_savepoint(true, 2024100701, 'qbank', 'columnsortorder');
|
||||
}
|
||||
|
||||
// Automatically generated Moodle v4.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
@ -26,6 +26,6 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = 'qbank_columnsortorder';
|
||||
$plugin->version = 2024100700;
|
||||
$plugin->version = 2024100701;
|
||||
$plugin->requires = 2024100100;
|
||||
$plugin->maturity = MATURITY_STABLE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user