mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-83691 core_sms: Avoid saving unnecessary data in the database
This commit is contained in:
parent
0888a6d324
commit
7dac99c191
3 changed files with 22 additions and 2 deletions
|
@ -1303,5 +1303,24 @@ function xmldb_main_upgrade($oldversion) {
|
||||||
upgrade_main_savepoint(true, 2024112900.02);
|
upgrade_main_savepoint(true, 2024112900.02);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($oldversion < 2024120500.01) {
|
||||||
|
$smsgateways = $DB->get_records('sms_gateways');
|
||||||
|
foreach ($smsgateways as $gateway) {
|
||||||
|
$newconfig = json_decode($gateway->config);
|
||||||
|
// Continue only if either the `returnurl` OR the `saveandreturn` property exists.
|
||||||
|
if (property_exists($newconfig, "returnurl") || property_exists($newconfig, "saveandreturn")) {
|
||||||
|
// Remove unnecessary data in the config.
|
||||||
|
unset($newconfig->returnurl, $newconfig->saveandreturn);
|
||||||
|
|
||||||
|
// Update the record with the new config.
|
||||||
|
$gateway->config = json_encode($newconfig);
|
||||||
|
$DB->update_record('sms_gateways', $gateway);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main savepoint reached.
|
||||||
|
upgrade_main_savepoint(true, 2024120500.01);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,8 @@ if ($data = $mform->get_data()) {
|
||||||
$manager = \core\di::get(\core_sms\manager::class);
|
$manager = \core\di::get(\core_sms\manager::class);
|
||||||
$smsgateway = $data->smsgateway;
|
$smsgateway = $data->smsgateway;
|
||||||
$gatewayname = $data->name;
|
$gatewayname = $data->name;
|
||||||
unset($data->smsgateway, $data->name, $data->id);
|
// The $data will go into the database config column. If any data is not needed, unset it here.
|
||||||
|
unset($data->smsgateway, $data->name, $data->id, $data->saveandreturn, $data->returnurl);
|
||||||
if (!empty($id)) {
|
if (!empty($id)) {
|
||||||
$gatewayinstance = $manager->get_gateway_instances(['id' => $id]);
|
$gatewayinstance = $manager->get_gateway_instances(['id' => $id]);
|
||||||
$gatewayinstance = reset($gatewayinstance);
|
$gatewayinstance = reset($gatewayinstance);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$version = 2024120500.00; // YYYYMMDD = weekly release date of this DEV branch.
|
$version = 2024120500.01; // YYYYMMDD = weekly release date of this DEV branch.
|
||||||
// RR = release increments - 00 in DEV branches.
|
// RR = release increments - 00 in DEV branches.
|
||||||
// .XX = incremental changes.
|
// .XX = incremental changes.
|
||||||
$release = '5.0dev (Build: 20241205)'; // Human-friendly version name
|
$release = '5.0dev (Build: 20241205)'; // Human-friendly version name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue