Merge branch 'wip-MDL-53492-master' of git://github.com/marinaglancy/moodle
authorDavid Monllao <davidm@moodle.com>
Tue, 1 Aug 2017 07:20:57 +0000 (09:20 +0200)
committerDavid Monllao <davidm@moodle.com>
Tue, 1 Aug 2017 07:20:57 +0000 (09:20 +0200)
1  2 
lib/db/upgrade.php
version.php

@@@ -2214,17 -2214,34 +2214,47 @@@ function xmldb_main_upgrade($oldversion
          upgrade_main_savepoint(true, 2017072000.02);
      }
  
 -    if ($oldversion < 2017072701.00) {
++<<<<<<< HEAD
 +    if ($oldversion < 2017072700.01) {
 +        // Changing nullability of field email on table oauth2_system_account to null.
 +        $table = new xmldb_table('oauth2_system_account');
 +        $field = new xmldb_field('email', XMLDB_TYPE_TEXT, null, null, null, null, null, 'grantedscopes');
 +
 +        // Launch change of nullability for field email.
 +        $dbman->change_field_notnull($table, $field);
 +
 +        // Main savepoint reached.
 +        upgrade_main_savepoint(true, 2017072700.01);
 +    }
 +
++    if ($oldversion < 2017072700.02) {
+         // If the site was previously registered with http://hub.moodle.org change the registration to
+         // point to https://moodle.net - this is the correct hub address using https protocol.
+         $oldhuburl = "http://hub.moodle.org";
+         $newhuburl = "https://moodle.net";
+         $cleanoldhuburl = preg_replace('/[^A-Za-z0-9_-]/i', '', $oldhuburl);
+         $cleannewhuburl = preg_replace('/[^A-Za-z0-9_-]/i', '', $newhuburl);
+         // Update existing registration.
+         $DB->execute("UPDATE {registration_hubs} SET hubname = ?, huburl = ? WHERE huburl = ?",
+             ['Moodle.net', $newhuburl, $oldhuburl]);
+         // Update settings of existing registration.
+         $sqlnamelike = $DB->sql_like('name', '?');
+         $entries = $DB->get_records_sql("SELECT * FROM {config_plugins} where plugin=? and " . $sqlnamelike,
+             ['hub', '%' . $DB->sql_like_escape('_' . $cleanoldhuburl)]);
+         foreach ($entries as $entry) {
+             $newname = substr($entry->name, 0, -strlen($cleanoldhuburl)) . $cleannewhuburl;
+             $DB->update_record('config_plugins', ['id' => $entry->id, 'name' => $newname]);
+         }
+         // Update published courses.
+         $DB->execute('UPDATE {course_published} SET huburl = ? WHERE huburl = ?', [$newhuburl, $oldhuburl]);
+         // Main savepoint reached.
 -        upgrade_main_savepoint(true, 2017072701.00);
++        upgrade_main_savepoint(true, 2017072700.02);
+     }
      return true;
  }
diff --cc version.php
@@@ -29,7 -29,7 +29,7 @@@
  
  defined('MOODLE_INTERNAL') || die();
  
- $version  = 2017072700.01;              // YYYYMMDD      = weekly release date of this DEV branch.
 -$version  = 2017072701.00;              // YYYYMMDD      = weekly release date of this DEV branch.
++$version  = 2017072700.02;              // YYYYMMDD      = weekly release date of this DEV branch.
                                          //         RR    = release increments - 00 in DEV branches.
                                          //           .XX = incremental changes.