MDL-65809 upgrade: remove upgrade_fix_block_instance_configuration
authorSara Arjona <sara@moodle.com>
Thu, 5 Dec 2019 10:52:23 +0000 (11:52 +0100)
committerSara Arjona <sara@moodle.com>
Fri, 20 Dec 2019 11:19:03 +0000 (12:19 +0100)
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.

admin/upgrade.txt
lib/db/upgrade.php
lib/db/upgradelib.php
lib/tests/upgradelib_test.php

index 68f18eb..9d0e28d 100644 (file)
@@ -1,5 +1,10 @@
 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).
index 91a1a20..5b357ff 100644 (file)
@@ -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');
index 89417ae..90e6ce0 100644 (file)
@@ -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.
  *
index 3aa0ecc..dde9579 100644 (file)
@@ -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.
      */