Commit c2303069 authored by Sara Arjona's avatar Sara Arjona
Browse files

MDL-65809 upgrade: remove upgrade_fix_block_instance_configuration

The upgrade_fix_block_instance_configuration() function was used
only by deleted upgrade steps so it's safe to proceed with straight
deletion, considering it internal. Deletion has been documented in
corresponding upgrade.txt files.
parent ad7fcff3
This files describes API changes in /admin/*.
=== 3.9 ===
* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info:
- upgrade_fix_block_instance_configuration()
=== 3.8 ===
* Admin setting "Open to Google" (opentogoogle) has been renamed to the more generic "Open to search engines" (opentowebcrawlers).
......
......@@ -1526,14 +1526,6 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2018020500.00);
}
if ($oldversion < 2018022800.01) {
// Fix old block configurations that use the deprecated (and now removed) object class.
upgrade_fix_block_instance_configuration();
// Main savepoint reached.
upgrade_main_savepoint(true, 2018022800.01);
}
if ($oldversion < 2018022800.02) {
// Define index taggeditem (unique) to be dropped form tag_instance.
$table = new xmldb_table('tag_instance');
......
......@@ -503,27 +503,6 @@ function upgrade_block_positions() {
$DB->execute($sql, ['']);
}
/**
* Fix configdata in block instances that are using the old object class that has been removed (deprecated).
*/
function upgrade_fix_block_instance_configuration() {
global $DB;
$sql = "SELECT *
FROM {block_instances}
WHERE " . $DB->sql_isnotempty('block_instances', 'configdata', true, true);
$blockinstances = $DB->get_recordset_sql($sql);
foreach ($blockinstances as $blockinstance) {
$configdata = base64_decode($blockinstance->configdata);
list($updated, $configdata) = upgrade_fix_serialized_objects($configdata);
if ($updated) {
$blockinstance->configdata = base64_encode($configdata);
$DB->update_record('block_instances', $blockinstance);
}
}
$blockinstances->close();
}
/**
* Provides a way to check and update a serialized string that uses the deprecated object class.
*
......
......@@ -890,36 +890,6 @@ class core_upgradelib_testcase extends advanced_testcase {
];
}
/**
* Check that entries in the block_instances table are coverted over correctly.
*
* @dataProvider encoded_strings_dataprovider
* @param string $original The original base64_encoded block config setting.
* @param string $expected The expected base64_encoded block config setting.
*/
public function test_upgrade_fix_block_instance_configuration($original, $expected) {
global $DB;
$this->resetAfterTest();
$data = new stdClass();
$data->blockname = 'html';
$data->parentcontextid = 1;
$data->showinsubcontexts = 0;
$data->requirebytheme = 0;
$data->pagetypepattern = 'admin-setting-frontpagesettings';
$data->defaultregion = 'side-post';
$data->defaultweight = 1;
$data->timecreated = time();
$data->timemodified = time();
$data->configdata = $original;
$entryid = $DB->insert_record('block_instances', $data);
upgrade_fix_block_instance_configuration();
$record = $DB->get_record('block_instances', ['id' => $entryid]);
$this->assertEquals($expected, $record->configdata);
}
/**
* Check that orphaned files are deleted.
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment