Merge branch 'MDL-65959-310' of git://github.com/peterRd/moodle into MOODLE_310_STABLE
authorSara Arjona <sara@moodle.com>
Mon, 26 Oct 2020 21:44:05 +0000 (22:44 +0100)
committerSara Arjona <sara@moodle.com>
Mon, 26 Oct 2020 21:44:05 +0000 (22:44 +0100)
1  2 
lib/db/install.xml
lib/db/upgrade.php
version.php

Simple merge
@@@ -2864,17 -2863,45 +2864,56 @@@ function xmldb_main_upgrade($oldversion
      }
  
      if ($oldversion < 2020102300.01) {
 -        global $DB, $CFG;
 +        // Define field downloadcontent to be added to course.
 +        $table = new xmldb_table('course');
 +        $field = new xmldb_field('downloadcontent', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'visibleold');
 +
 +        if (!$dbman->field_exists($table, $field)) {
 +            $dbman->add_field($table, $field);
 +        }
  
 -        upgrade_main_savepoint(true, 2020102300.01);
 +        // Main savepoint reached.
 +        upgrade_main_savepoint(true, 2020102300.01);
 +    }
 +
++    if ($oldversion < 2020102300.02) {
+         $table = new xmldb_table('badge_backpack');
+         $uniquekey = new xmldb_key('backpackcredentials', XMLDB_KEY_UNIQUE, ['userid', 'externalbackpackid']);
+         // All external backpack providers/hosts are now exclusively stored in badge_external_backpack.
+         // All credentials are stored in badge_backpack and are unique per user, backpack.
+         if (!$dbman->find_key_name($table, $uniquekey)) {
+             $dbman->add_key($table, $uniquekey);
+         }
+         // If there is a current backpack set then copy it across to the new structure.
+         if ($CFG->badges_defaultissuercontact) {
+             // Get the currently used site backpacks.
+             $records = $DB->get_records_select('badge_external_backpack', "password IS NOT NULL AND password != ''");
+             $backpack = [
+                 'userid' => '0',
+                 'email' => $CFG->badges_defaultissuercontact,
+                 'backpackuid' => -1
+             ];
+             // Create records corresponding to the site backpacks.
+             foreach ($records as $record) {
+                 $backpack['password'] = $record->password;
+                 $backpack['externalbackpackid'] = $record->id;
+                 $DB->insert_record('badge_backpack', (object) $backpack);
+             }
+         }
+         // Drop the password field as this is moved to badge_backpack.
+         $table = new xmldb_table('badge_external_backpack');
+         $field = new xmldb_field('password', XMLDB_TYPE_CHAR, '50');
+         if ($dbman->field_exists($table, $field)) {
+             $dbman->drop_field($table, $field);
+         }
+         // Main savepoint reached.
++        upgrade_main_savepoint(true, 2020102300.02);
+     }
      return true;
  }
diff --cc version.php
@@@ -29,7 -29,7 +29,7 @@@
  
  defined('MOODLE_INTERNAL') || die();
  
--$version  = 2020102300.01;              // YYYYMMDD      = weekly release date of this DEV branch.
++$version  = 2020102300.02;              // YYYYMMDD      = weekly release date of this DEV branch.
                                          //         RR    = release increments - 00 in DEV branches.
                                          //           .XX = incremental changes.
  $release  = '3.10dev+ (Build: 20201023)';// Human-friendly version name