MDL-73747 core_messages: Complete default preferences on migration

Co-authored-by: Jun pataleta <jun@moodle.com>
This commit is contained in:
Amaia Anabitarte 2022-02-23 09:27:25 +01:00
parent 9cd77c4130
commit acca36d2ad
2 changed files with 24 additions and 1 deletions

View File

@ -3651,6 +3651,8 @@ privatefiles,moodle|/user/files.php';
// Save locked.
if ($locked) {
set_config($provider.'_provider_'.$prefname.'_locked', 1, 'message');
} else {
set_config($provider.'_provider_'.$prefname.'_locked', 0, 'message');
}
// Remove old value.
unset_config($provider.'_provider_'.$prefname.'_permitted', 'message');
@ -4107,5 +4109,26 @@ privatefiles,moodle|/user/files.php';
upgrade_main_savepoint(true, 2022021100.02);
}
if ($oldversion < 2022022600.01) {
// Get all processor and existing preferences.
$processors = $DB->get_records('message_processors');
$providers = $DB->get_records('message_providers', null, '', 'id, name, component');
$existingpreferences = get_config('message');
foreach ($processors as $processor) {
foreach ($providers as $provider) {
// Setting default preference name.
$componentproviderbase = $provider->component . '_' . $provider->name;
$preferencename = $processor->name.'_provider_'.$componentproviderbase.'_locked';
// If we do not have this setting yet, set it to 0.
if (!isset($existingpreferences->{$preferencename})) {
set_config($preferencename, 0, 'message');
}
}
}
upgrade_main_savepoint(true, 2022022600.01);
}
return true;
}

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2022022600.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2022022600.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.0dev+ (Build: 20220226)'; // Human-friendly version name