MDL-66118 hub: Stop using the hub URL as the setting name suffix
[moodle.git] / lib / db / upgrade.php
index 5ab80e9..425deab 100644 (file)
@@ -3556,5 +3556,23 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint(true, 2019092700.01);
     }
 
+    if ($oldversion < 2019100400.01) {
+        // Rename the official moodle sites directory the site is registered with.
+        $DB->execute("UPDATE {registration_hubs}
+                         SET hubname = ?, huburl = ?
+                       WHERE huburl = ?", ['moodle', 'https://stats.moodle.org', 'https://moodle.net']);
+
+        // Convert the hub site specific settings to the new naming format without the hub URL in the name.
+        $hubconfig = get_config('hub');
+
+        if (!empty($hubconfig)) {
+            foreach (upgrade_convert_hub_config_site_param_names($hubconfig, 'https://moodle.net') as $name => $value) {
+                set_config($name, $value, 'hub');
+            }
+        }
+
+        upgrade_main_savepoint(true, 2019100400.01);
+    }
+
     return true;
 }