diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index ea03d361871be..5d4bb8f817961 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -3,6 +3,7 @@ name: Core
on:
push:
branches-ignore:
+ - main
- master
- MOODLE_[0-9]+_STABLE
tags-ignore:
@@ -62,7 +63,7 @@ jobs:
include:
# MySQL builds always run with the lowest PHP supported version.
- os: ubuntu-22.04
- php: 8.0
+ php: 8.1
extensions:
db: mysqli
# PostgreSQL builds always run with the highest PHP supported version.
diff --git a/admin/environment.xml b/admin/environment.xml
index 502d2dab073e6..45d774ed111ef 100644
--- a/admin/environment.xml
+++ b/admin/environment.xml
@@ -4305,4 +4305,195 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/admin/tool/cohortroles/db/upgrade.php b/admin/tool/cohortroles/db/upgrade.php
index c9ea8cc2477ef..b102f5b7a2b1b 100644
--- a/admin/tool/cohortroles/db/upgrade.php
+++ b/admin/tool/cohortroles/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade tool_cohortroles.
*
@@ -33,20 +31,6 @@
function xmldb_tool_cohortroles_upgrade($oldversion) {
global $DB;
- if ($oldversion < 2020020600) {
- // Delete any tool_cohortroles mappings for roles which no longer exist.
- $DB->delete_records_select('tool_cohortroles', 'roleid NOT IN (SELECT id FROM {role})');
-
- // Cohortroles savepoint reached.
- upgrade_plugin_savepoint(true, 2020020600, 'tool', 'cohortroles');
- }
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/admin/tool/customlang/db/upgrade.php b/admin/tool/customlang/db/upgrade.php
index f46d70fd663ab..d9182cf16e3f1 100644
--- a/admin/tool/customlang/db/upgrade.php
+++ b/admin/tool/customlang/db/upgrade.php
@@ -1,5 +1,4 @@
get_manager();
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2020061501) {
-
- // Define field commentsformat to be added to tool_dataprivacy_request.
- $table = new xmldb_table('tool_dataprivacy_request');
- $field = new xmldb_field('commentsformat', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'comments');
-
- // Conditionally launch add field commentsformat.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field dpocommentformat to be added to tool_dataprivacy_request.
- $field = new xmldb_field('dpocommentformat', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'dpocomment');
-
- // Conditionally launch add field dpocommentformat.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field systemapproved to be added to tool_dataprivacy_request.
- $field = new xmldb_field('systemapproved', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'dpocommentformat');
-
- // Conditionally launch add field systemapproved.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Dataprivacy savepoint reached.
- upgrade_plugin_savepoint(true, 2020061501, 'tool', 'dataprivacy');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
- if ($oldversion < 2022053000) {
-
- // Define key usermodified (foreign) to be added to tool_dataprivacy_purposerole.
- $table = new xmldb_table('tool_dataprivacy_purposerole');
- $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
-
- // Launch add key usermodified.
- $dbman->add_key($table, $key);
-
- // Dataprivacy savepoint reached.
- upgrade_plugin_savepoint(true, 2022053000, 'tool', 'dataprivacy');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
@@ -91,7 +40,6 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) {
// Put any upgrade step following this.
if ($oldversion < 2023062700) {
-
// Define table tool_dataprivacy_contextlist to be created.
$table = new xmldb_table('tool_dataprivacy_contextlist');
diff --git a/admin/tool/log/db/upgrade.php b/admin/tool/log/db/upgrade.php
index a208252c1ddfd..5420435a18ee9 100644
--- a/admin/tool/log/db/upgrade.php
+++ b/admin/tool/log/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade the plugin.
*
@@ -31,14 +29,6 @@
* @return bool always true
*/
function xmldb_tool_log_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/admin/tool/log/store/database/db/upgrade.php b/admin/tool/log/store/database/db/upgrade.php
index 065861d1020bb..bcc48974d653d 100644
--- a/admin/tool/log/store/database/db/upgrade.php
+++ b/admin/tool/log/store/database/db/upgrade.php
@@ -22,17 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_logstore_database_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/admin/tool/log/store/standard/db/upgrade.php b/admin/tool/log/store/standard/db/upgrade.php
index 35eb66b00b72e..1f2d4862554b7 100644
--- a/admin/tool/log/store/standard/db/upgrade.php
+++ b/admin/tool/log/store/standard/db/upgrade.php
@@ -22,44 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_logstore_standard_upgrade($oldversion) {
- global $CFG, $DB;
-
- require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions.
-
- $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
- if ($oldversion < 2022053000) {
- // Define index relateduserid (not unique) to be added to logstore_standard_log.
- $table = new xmldb_table('logstore_standard_log');
-
- // Launch add key userid.
- $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
- $dbman->add_key($table, $key);
-
- // Launch add key courseid.
- $key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']);
- $dbman->add_key($table, $key);
-
- // Launch add key realuserid.
- $key = new xmldb_key('realuserid', XMLDB_KEY_FOREIGN, ['realuserid'], 'user', ['id']);
- $dbman->add_key($table, $key);
-
- // Launch add key relateduserid.
- $key = new xmldb_key('relateduserid', XMLDB_KEY_FOREIGN, ['relateduserid'], 'user', ['id']);
- $dbman->add_key($table, $key);
-
- // Standard savepoint reached.
- upgrade_plugin_savepoint(true, 2022053000, 'logstore', 'standard');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/admin/tool/mfa/factor/auth/db/upgrade.php b/admin/tool/mfa/factor/auth/db/upgrade.php
index 37a4be952c594..ed8a4bd52e54d 100644
--- a/admin/tool/mfa/factor/auth/db/upgrade.php
+++ b/admin/tool/mfa/factor/auth/db/upgrade.php
@@ -28,7 +28,6 @@
* @param int $oldversion
*/
function xmldb_factor_auth_upgrade($oldversion) {
-
if ($oldversion < 2021020500) {
$authtypes = get_enabled_auth_plugins(true);
// Upgrade goodauth config from number to name.
diff --git a/admin/tool/mobile/db/upgrade.php b/admin/tool/mobile/db/upgrade.php
index 5eb27245ffd37..f5d3de9dafa69 100644
--- a/admin/tool/mobile/db/upgrade.php
+++ b/admin/tool/mobile/db/upgrade.php
@@ -22,10 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
-require_once($CFG->dirroot . '/lib/upgradelib.php');
-
/**
* Upgrade the plugin.
*
@@ -33,14 +29,6 @@
* @return bool always true
*/
function xmldb_tool_mobile_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/admin/tool/monitor/db/upgrade.php b/admin/tool/monitor/db/upgrade.php
index 08b52eba871ce..6036e73ea5fe8 100644
--- a/admin/tool/monitor/db/upgrade.php
+++ b/admin/tool/monitor/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade the plugin.
*
@@ -31,44 +29,6 @@
* @return bool always true
*/
function xmldb_tool_monitor_upgrade($oldversion) {
- global $CFG, $DB;
-
- require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions.
-
- $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
- if ($oldversion < 2022053000) {
-
- // Define key courseid (foreign) to be added to tool_monitor_events.
- $table = new xmldb_table('tool_monitor_events');
- $key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']);
-
- // Launch add key courseid.
- $dbman->add_key($table, $key);
-
- // Define key contextid (foreign) to be added to tool_monitor_events.
- $table = new xmldb_table('tool_monitor_events');
- $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']);
-
- // Launch add key contextid.
- $dbman->add_key($table, $key);
-
- // Define key contextinstanceid (foreign) to be added to tool_monitor_events.
- $table = new xmldb_table('tool_monitor_events');
- $key = new xmldb_key('contextinstanceid', XMLDB_KEY_FOREIGN, ['contextinstanceid'], 'context', ['instanceid']);
-
- // Launch add key contextinstanceid.
- $dbman->add_key($table, $key);
-
- // Monitor savepoint reached.
- upgrade_plugin_savepoint(true, 2022053000, 'tool', 'monitor');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/admin/tool/moodlenet/db/upgrade.php b/admin/tool/moodlenet/db/upgrade.php
index 7f87047bf5b2c..649e3df0f9e84 100644
--- a/admin/tool/moodlenet/db/upgrade.php
+++ b/admin/tool/moodlenet/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade the plugin.
*
@@ -31,124 +29,6 @@
* @return bool always true
*/
function xmldb_tool_moodlenet_upgrade(int $oldversion) {
- global $CFG, $DB;
- if ($oldversion < 2020060500) {
-
- // Grab some of the old settings.
- $categoryname = get_config('tool_moodlenet', 'profile_category');
- $profilefield = get_config('tool_moodlenet', 'profile_field_name');
-
- // Master version only!
-
- // Find out if we have a custom profile field for moodle.net.
- $sql = "SELECT f.*
- FROM {user_info_field} f
- JOIN {user_info_category} c ON c.id = f.categoryid and c.name = :categoryname
- WHERE f.shortname = :name";
-
- $params = [
- 'categoryname' => $categoryname,
- 'name' => $profilefield
- ];
-
- $record = $DB->get_record_sql($sql, $params);
-
- if (!empty($record)) {
- $userentries = $DB->get_recordset('user_info_data', ['fieldid' => $record->id]);
- $recordstodelete = [];
- foreach ($userentries as $userentry) {
- $data = (object) [
- 'id' => $userentry->userid,
- 'moodlenetprofile' => $userentry->data
- ];
- $DB->update_record('user', $data, true);
- $recordstodelete[] = $userentry->id;
- }
- $userentries->close();
-
- // Remove the user profile data, fields, and category.
- $DB->delete_records_list('user_info_data', 'id', $recordstodelete);
- $DB->delete_records('user_info_field', ['id' => $record->id]);
- $DB->delete_records('user_info_category', ['name' => $categoryname]);
- unset_config('profile_field_name', 'tool_moodlenet');
- unset_config('profile_category', 'tool_moodlenet');
- }
-
- upgrade_plugin_savepoint(true, 2020060500, 'tool', 'moodlenet');
- }
-
- if ($oldversion < 2020061501) {
- // Change the domain.
- $defaultmoodlenet = get_config('tool_moodlenet', 'defaultmoodlenet');
-
- if ($defaultmoodlenet === 'https://home.moodle.net') {
- set_config('defaultmoodlenet', 'https://moodle.net', 'tool_moodlenet');
- }
-
- // Change the name.
- $defaultmoodlenetname = get_config('tool_moodlenet', 'defaultmoodlenetname');
-
- if ($defaultmoodlenetname === 'Moodle HQ MoodleNet') {
- set_config('defaultmoodlenetname', 'MoodleNet Central', 'tool_moodlenet');
- }
-
- upgrade_plugin_savepoint(true, 2020061501, 'tool', 'moodlenet');
- }
-
- if ($oldversion < 2020061502) {
- // Disable the MoodleNet integration by default till further notice.
- set_config('enablemoodlenet', 0, 'tool_moodlenet');
-
- upgrade_plugin_savepoint(true, 2020061502, 'tool', 'moodlenet');
- }
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022021600) {
- // This is a special case for if MoodleNet integration has never been enabled,
- // or if defaultmoodlenet is not set for whatever reason.
- if (!get_config('tool_moodlenet', 'defaultmoodlenet')) {
- set_config('defaultmoodlenet', 'https://moodle.net', 'tool_moodlenet');
- set_config('defaultmoodlenetname', get_string('defaultmoodlenetnamevalue', 'tool_moodlenet'), 'tool_moodlenet');
- }
-
- // Enable MoodleNet and set it to display on activity chooser footer.
- // But only do this if we know for sure that the default MoodleNet is a working one.
- if (get_config('tool_moodlenet', 'defaultmoodlenet') == 'https://moodle.net') {
- set_config('enablemoodlenet', '1', 'tool_moodlenet');
- set_config('activitychooseractivefooter', 'tool_moodlenet');
-
- // Use an adhoc task to send a notification to admin stating MoodleNet is automatically enabled after upgrade.
- $notificationtask = new tool_moodlenet\task\send_enable_notification();
- core\task\manager::queue_adhoc_task($notificationtask);
- }
-
- upgrade_plugin_savepoint(true, 2022021600, 'tool', 'moodlenet');
- }
-
- if ($oldversion < 2022021601) {
-
- $selectsql = "moodlenetprofile IS NOT NULL AND moodlenetprofile != ''";
-
- // If there are any users with MoodleNet profile set.
- if ($DB->count_records_select('user', $selectsql)) {
- // Remove the value set for the MoodleNet profile as this format can no longer be used to authenticate
- // MoodleNet users.
- $DB->set_field_select('user', 'moodlenetprofile', '', $selectsql);
-
- // Use an adhoc task to send a notification to admin stating that the user data related to the linked
- // MoodleNet profiles has been removed.
- $notificationtask = new tool_moodlenet\task\send_mnet_profiles_data_removed_notification();
- core\task\manager::queue_adhoc_task($notificationtask);
- }
-
- upgrade_plugin_savepoint(true, 2022021601, 'tool', 'moodlenet');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/admin/tool/policy/db/upgrade.php b/admin/tool/policy/db/upgrade.php
index 25abdb5ecb6f8..dc6e448ba7c74 100644
--- a/admin/tool/policy/db/upgrade.php
+++ b/admin/tool/policy/db/upgrade.php
@@ -23,8 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Execute the plugin upgrade steps from the given old version.
*
@@ -32,14 +30,6 @@
* @return bool
*/
function xmldb_tool_policy_upgrade($oldversion) {
- global $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/admin/tool/usertours/db/upgrade.php b/admin/tool/usertours/db/upgrade.php
index 7eb64410b7e44..d0b7b12221847 100644
--- a/admin/tool/usertours/db/upgrade.php
+++ b/admin/tool/usertours/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
use tool_usertours\manager;
use tool_usertours\tour;
@@ -34,104 +32,6 @@
* @return bool
*/
function xmldb_tool_usertours_upgrade($oldversion) {
- global $CFG, $DB;
-
- $dbman = $DB->get_manager();
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
- // Clean up user preferences of deleted tours.
- $select = $DB->sql_like('name', ':lastcompleted') . ' OR ' . $DB->sql_like('name', ':requested');
- $params = [
- 'lastcompleted' => tour::TOUR_LAST_COMPLETED_BY_USER . '%',
- 'requested' => tour::TOUR_REQUESTED_BY_USER . '%',
- ];
-
- $preferences = $DB->get_records_select('user_preferences', $select, $params, '', 'DISTINCT name');
- foreach ($preferences as $preference) {
- // Match tour ID at the end of the preference name, remove all of that preference type if tour ID doesn't exist.
- if (preg_match('/(?\d+)$/', $preference->name, $matches) &&
- !$DB->record_exists('tool_usertours_tours', ['id' => $matches['tourid']])) {
-
- $DB->delete_records('user_preferences', ['name' => $preference->name]);
- }
- }
-
- upgrade_plugin_savepoint(true, 2021052501, 'tool', 'usertours');
- }
-
- if ($oldversion < 2021092300) {
- // Define field endtourlabel to be added to tool_usertours_tours.
- $table = new xmldb_table('tool_usertours_tours');
- $field = new xmldb_field('endtourlabel', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'sortorder');
-
- // Conditionally launch add field endtourlabel.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Usertours savepoint reached.
- upgrade_plugin_savepoint(true, 2021092300, 'tool', 'usertours');
- }
-
- if ($oldversion < 2021100700) {
-
- // Define field displaystepnumbers to be added to tool_usertours_tours.
- $table = new xmldb_table('tool_usertours_tours');
- $field = new xmldb_field('displaystepnumbers', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'configdata');
-
- // Conditionally launch add field displaystepnumbers.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Usertours savepoint reached.
- upgrade_plugin_savepoint(true, 2021100700, 'tool', 'usertours');
- }
-
- if ($oldversion < 2022040601) {
- // Define field contentformat to be added to tool_usertours_steps.
- $table = new xmldb_table('tool_usertours_steps');
- $field = new xmldb_field('contentformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, FORMAT_MOODLE, 'content');
-
- // Conditionally launch add field contentformat.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- } else {
- // Field was added by previous upgrade step with the default value is FORMAT_HTML.
- // Need to drop the field and re-create with the new structure to make sure all the existing tours use FORMAT_MOODLE.
- // FORMAT_MOODLE will force the \core_external\util::format_text method to use nl2br to
- // convert the new line to line break tag.
- $dbman->drop_field($table, $field);
- // Add the field again.
- $dbman->add_field($table, $field);
- }
-
- // Usertours savepoint reached.
- upgrade_plugin_savepoint(true, 2022040601, 'tool', 'usertours');
- }
-
- if ($oldversion < 2022040602) {
- // Update shipped tours.
- // Normally, we just bump the version numbers because we need to call update_shipped_tours only once.
- manager::update_shipped_tours();
-
- upgrade_plugin_savepoint(true, 2022040602, 'tool', 'usertours');
- }
-
- if ($oldversion < 2022061600) {
- // Update shipped tours.
- // Normally, we just bump the version numbers because we need to call update_shipped_tours only once.
- manager::update_shipped_tours();
-
- upgrade_plugin_savepoint(true, 2022061600, 'tool', 'usertours');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/auth/cas/db/upgrade.php b/auth/cas/db/upgrade.php
index 887366082b687..41bdd4130578d 100644
--- a/auth/cas/db/upgrade.php
+++ b/auth/cas/db/upgrade.php
@@ -22,30 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade auth_cas.
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_auth_cas_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
- // Normalize the memberattribute_isdn plugin config.
- set_config('memberattribute_isdn',
- !empty(get_config('auth_cas', 'memberattribute_isdn')), 'auth_cas');
-
- upgrade_plugin_savepoint(true, 2021052501, 'auth', 'cas');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/auth/db/db/upgrade.php b/auth/db/db/upgrade.php
index 15e68bfb3a1bb..eb5b0994cc9d9 100644
--- a/auth/db/db/upgrade.php
+++ b/auth/db/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade auth_db.
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_auth_db_upgrade($oldversion) {
- global $CFG, $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/auth/email/db/upgrade.php b/auth/email/db/upgrade.php
index ff242af6bb27a..ec4e562460797 100644
--- a/auth/email/db/upgrade.php
+++ b/auth/email/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade auth_email.
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_auth_email_upgrade($oldversion) {
- global $CFG, $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/auth/ldap/db/upgrade.php b/auth/ldap/db/upgrade.php
index 00b48e5158dac..3e3e0cf225939 100644
--- a/auth/ldap/db/upgrade.php
+++ b/auth/ldap/db/upgrade.php
@@ -22,30 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade auth_ldap.
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_auth_ldap_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
- // Normalize the memberattribute_isdn plugin config.
- set_config('memberattribute_isdn',
- !empty(get_config('auth_ldap', 'memberattribute_isdn')), 'auth_ldap');
-
- upgrade_plugin_savepoint(true, 2021052501, 'auth', 'ldap');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/auth/lti/db/upgrade.php b/auth/lti/db/upgrade.php
index d5bd1dd5603a1..bce94faf1aac9 100644
--- a/auth/lti/db/upgrade.php
+++ b/auth/lti/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade function.
*
@@ -31,63 +29,6 @@
* @return bool result.
*/
function xmldb_auth_lti_upgrade($oldversion) {
- global $DB;
-
- $dbman = $DB->get_manager();
-
- if ($oldversion < 2021100500) {
- // Define table auth_lti_linked_login to be created.
- $table = new xmldb_table('auth_lti_linked_login');
-
- // Adding fields to table auth_lti_linked_login.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('issuer', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('issuer256', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null);
- $table->add_field('sub', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('sub256', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-
- // Adding keys to table auth_lti_linked_login.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('userid_key', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
- $table->add_key('unique_key', XMLDB_KEY_UNIQUE, ['userid', 'issuer256', 'sub256']);
-
- // Conditionally launch create table for auth_lti_linked_login.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Auth LTI savepoint reached.
- upgrade_plugin_savepoint(true, 2021100500, 'auth', 'lti');
- }
-
- if ($oldversion < 2022030900) {
- // Fix the unique key made up of {userid, issuer256, sub256}.
- // This was improperly defined as ['userid, issuer256, sub256'] in the upgrade step above (note the quotes),
- // resulting in the potential for missing keys on some databases.
- // Drop and re-add the key to make sure we have it in place.
-
- // Define table auth_lti_linked_login to be modified.
- $table = new xmldb_table('auth_lti_linked_login');
-
- // Define the key to be dropped and re-added.
- $key = new xmldb_key('unique_key', XMLDB_KEY_UNIQUE, ['userid', 'issuer256', 'sub256'], 'auth_lti_linked_login');
-
- // Drop the key.
- $dbman->drop_key($table, $key);
-
- // Create the key.
- $dbman->add_key($table, $key);
-
- // Auth LTI savepoint reached.
- upgrade_plugin_savepoint(true, 2022030900, 'auth', 'lti');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/auth/manual/db/upgrade.php b/auth/manual/db/upgrade.php
index 39c30739b85c5..39d64b74cfdb1 100644
--- a/auth/manual/db/upgrade.php
+++ b/auth/manual/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade auth_manual.
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_auth_manual_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/auth/mnet/db/upgrade.php b/auth/mnet/db/upgrade.php
index aef5406893131..59430a9c65900 100644
--- a/auth/mnet/db/upgrade.php
+++ b/auth/mnet/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade auth_mnet.
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_auth_mnet_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/auth/none/db/upgrade.php b/auth/none/db/upgrade.php
index 43754da3a0cb8..e5f98fbbfffdf 100644
--- a/auth/none/db/upgrade.php
+++ b/auth/none/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade auth_none.
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_auth_none_upgrade($oldversion) {
- global $CFG, $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/auth/oauth2/db/upgrade.php b/auth/oauth2/db/upgrade.php
index 11db31b226647..9aec2b1b941d3 100644
--- a/auth/oauth2/db/upgrade.php
+++ b/auth/oauth2/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade function
*
@@ -31,14 +29,6 @@
* @return bool result
*/
function xmldb_auth_oauth2_upgrade($oldversion) {
- global $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/auth/shibboleth/db/upgrade.php b/auth/shibboleth/db/upgrade.php
index 6298db677cbbf..cf9ffd6824a56 100644
--- a/auth/shibboleth/db/upgrade.php
+++ b/auth/shibboleth/db/upgrade.php
@@ -22,44 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade auth_shibboleth.
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_auth_shibboleth_upgrade($oldversion) {
- global $CFG, $DB, $OUTPUT;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
- // The 'Data modification API' setting in the Shibboleth authentication plugin can no longer be configured
- // to use files located within the site data directory, as it exposes the site to security risks. Therefore,
- // we need to find every existing case and reset the 'Data modification API' setting to its default value.
-
- $convertdataconfig = get_config('auth_shibboleth', 'convert_data');
-
- if (preg_match('/' . preg_quote($CFG->dataroot, '/') . '/', realpath($convertdataconfig))) {
- set_config('convert_data', '', 'auth_shibboleth');
-
- $warn = 'Your \'Data modification API\' setting in the Shibboleth authentication plugin is currently
- configured to use a file located within the current site data directory ($CFG->dataroot). You are no
- longer able to use files from within this directory for this purpose as it exposes your site to security
- risks. This setting has been reset to its default value. Please reconfigure it by providing a path
- to a file which is not located within the site data directory.';
-
- echo $OUTPUT->notification($warn, 'notifyproblem');
- }
-
- upgrade_plugin_savepoint(true, 2021052501, 'auth', 'shibboleth');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/badges/db/upgrade.php b/blocks/badges/db/upgrade.php
index 01d04ff58e023..5defadbf4a4b1 100644
--- a/blocks/badges/db/upgrade.php
+++ b/blocks/badges/db/upgrade.php
@@ -43,14 +43,6 @@
* @param object $block
*/
function xmldb_block_badges_upgrade($oldversion, $block) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/calendar_month/db/upgrade.php b/blocks/calendar_month/db/upgrade.php
index 43b787ea01443..d2ccf94793502 100644
--- a/blocks/calendar_month/db/upgrade.php
+++ b/blocks/calendar_month/db/upgrade.php
@@ -37,35 +37,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
-require_once("{$CFG->libdir}/db/upgradelib.php");
-
/**
* Upgrade the calendar_month block
* @param int $oldversion
* @param object $block
*/
function xmldb_block_calendar_month_upgrade($oldversion, $block) {
- global $CFG, $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022030200) {
- // Update all calendar_month blocks in the my-index to be in the main content region.
- upgrade_block_set_defaultregion('calendar_month', '__default', 'my-index', 'content');
- upgrade_block_savepoint(true, 2022030200, 'calendar_month', false);
- }
-
- if ($oldversion < 2022041901) {
- upgrade_block_set_my_user_parent_context('calendar_month', '__default', 'my-index');
- upgrade_block_savepoint(true, 2022041901, 'calendar_month', false);
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/calendar_upcoming/db/upgrade.php b/blocks/calendar_upcoming/db/upgrade.php
index 95bea7412b57d..8defbb45d1ade 100644
--- a/blocks/calendar_upcoming/db/upgrade.php
+++ b/blocks/calendar_upcoming/db/upgrade.php
@@ -43,14 +43,6 @@
* @param object $block
*/
function xmldb_block_calendar_upcoming_upgrade($oldversion, $block) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/completionstatus/db/upgrade.php b/blocks/completionstatus/db/upgrade.php
index e142d74801a23..70930bd0f4d26 100644
--- a/blocks/completionstatus/db/upgrade.php
+++ b/blocks/completionstatus/db/upgrade.php
@@ -37,8 +37,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Handles upgrading instances of this block.
*
@@ -46,14 +44,6 @@
* @param object $block
*/
function xmldb_block_completionstatus_upgrade($oldversion, $block) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/course_summary/db/upgrade.php b/blocks/course_summary/db/upgrade.php
index dd8001ba09a88..41473c0dd9663 100644
--- a/blocks/course_summary/db/upgrade.php
+++ b/blocks/course_summary/db/upgrade.php
@@ -37,8 +37,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Handles upgrading instances of this block.
*
@@ -46,25 +44,6 @@
* @param object $block
*/
function xmldb_block_course_summary_upgrade($oldversion, $block) {
- global $CFG, $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021121600) {
- // From Moodle 4.0, this block has been disabled by default in new installations.
- // If the site has no instances of this block, it will disabled during the upgrading process too.
- $totalcount = $DB->count_records('block_instances', ['blockname' => 'course_summary']);
- if ($totalcount == 0) {
- $DB->set_field('block', 'visible', 0, ['name' => 'course_summary']);
- }
-
- upgrade_block_savepoint(true, 2021121600, 'course_summary', false);
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/feedback/db/upgrade.php b/blocks/feedback/db/upgrade.php
index b61fb47fa4614..93dcaf8c7b7e8 100644
--- a/blocks/feedback/db/upgrade.php
+++ b/blocks/feedback/db/upgrade.php
@@ -36,8 +36,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Handles upgrading instances of this block.
*
@@ -45,22 +43,6 @@
* @param object $block
*/
function xmldb_block_feedback_upgrade($oldversion, $block) {
- global $CFG, $DB;
-
- if ($oldversion < 2021121600) {
- // From Moodle 4.0, this block has been disabled by default in new installations.
- // If the site has no instances of this block, it will disabled during the upgrading process too.
- $totalcount = $DB->count_records('block_instances', ['blockname' => 'feedback']);
- if ($totalcount == 0) {
- $DB->set_field('block', 'visible', 0, ['name' => 'feedback']);
- }
-
- upgrade_block_savepoint(true, 2021121600, 'feedback', false);
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/html/db/upgrade.php b/blocks/html/db/upgrade.php
index 6aa6da903a8a1..d4637d1cbc23f 100644
--- a/blocks/html/db/upgrade.php
+++ b/blocks/html/db/upgrade.php
@@ -23,22 +23,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the HTML block.
*
* @param int $oldversion
*/
function xmldb_block_html_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/myoverview/db/upgrade.php b/blocks/myoverview/db/upgrade.php
index a3c36182783f9..c124b7788d8ff 100644
--- a/blocks/myoverview/db/upgrade.php
+++ b/blocks/myoverview/db/upgrade.php
@@ -23,61 +23,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
-require_once("{$CFG->dirroot}/my/lib.php");
-require_once("{$CFG->libdir}/db/upgradelib.php");
-
/**
* Upgrade code for the MyOverview block.
*
* @param int $oldversion
*/
function xmldb_block_myoverview_upgrade($oldversion) {
- global $DB, $CFG, $OUTPUT;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052504) {
- upgrade_block_delete_instances('myoverview', '__default', 'my-index');
-
- // Add new instance to the /my/courses.php page.
- $subpagepattern = $DB->get_record('my_pages', [
- 'userid' => null,
- 'name' => MY_PAGE_COURSES,
- 'private' => MY_PAGE_PUBLIC,
- ], 'id', IGNORE_MULTIPLE)->id;
-
- $blockname = 'myoverview';
- $pagetypepattern = 'my-index';
-
- $blockparams = [
- 'blockname' => $blockname,
- 'pagetypepattern' => $pagetypepattern,
- 'subpagepattern' => $subpagepattern,
- ];
-
- // See if this block already somehow exists, it should not but who knows.
- if (!$DB->record_exists('block_instances', $blockparams)) {
- $page = new moodle_page();
- $page->set_context(context_system::instance());
- // Add the block to the default /my/courses.
- $page->blocks->add_region('content');
- $page->blocks->add_block($blockname, 'content', 0, false, $pagetypepattern, $subpagepattern);
- }
-
- upgrade_block_savepoint(true, 2021052504, 'myoverview', false);
- }
-
- if ($oldversion < 2022041901) {
- upgrade_block_set_my_user_parent_context('myoverview', '__default', 'my-index');
- upgrade_block_savepoint(true, 2022041901, 'myoverview', false);
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/navigation/db/upgrade.php b/blocks/navigation/db/upgrade.php
index 8210f99ee595b..d0f7187a874ad 100644
--- a/blocks/navigation/db/upgrade.php
+++ b/blocks/navigation/db/upgrade.php
@@ -37,8 +37,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* As of the implementation of this block and the general navigation code
* in Moodle 2.0 the body of immediate upgrade work for this block and
@@ -53,14 +51,6 @@
* @param object $block
*/
function xmldb_block_navigation_upgrade($oldversion, $block) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/recent_activity/db/upgrade.php b/blocks/recent_activity/db/upgrade.php
index 46e06ed1638d0..cedeeca7caa30 100644
--- a/blocks/recent_activity/db/upgrade.php
+++ b/blocks/recent_activity/db/upgrade.php
@@ -36,8 +36,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the recent activity block.
*
@@ -45,14 +43,6 @@
* @param object $block
*/
function xmldb_block_recent_activity_upgrade($oldversion, $block) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/recentlyaccesseditems/db/upgrade.php b/blocks/recentlyaccesseditems/db/upgrade.php
index 151687d272530..2073e881d4866 100644
--- a/blocks/recentlyaccesseditems/db/upgrade.php
+++ b/blocks/recentlyaccesseditems/db/upgrade.php
@@ -36,10 +36,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
-require_once("{$CFG->libdir}/db/upgradelib.php");
-
/**
* Upgrade the recentlyaccesseditems db table.
*
@@ -47,25 +43,6 @@
* @return bool
*/
function xmldb_block_recentlyaccesseditems_upgrade($oldversion, $block) {
- global $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022030200) {
- // Update all recentlyaccesseditems blocks in the my-index to be in the main side-post region.
- upgrade_block_set_defaultregion('recentlyaccesseditems', '__default', 'my-index', 'side-post');
- upgrade_block_savepoint(true, 2022030200, 'recentlyaccesseditems', false);
- }
-
- if ($oldversion < 2022041901) {
- upgrade_block_set_my_user_parent_context('recentlyaccesseditems', '__default', 'my-index');
- upgrade_block_savepoint(true, 2022041901, 'recentlyaccesseditems', false);
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/rss_client/db/upgrade.php b/blocks/rss_client/db/upgrade.php
index f1cec9cbb51ec..521b2b834ae77 100644
--- a/blocks/rss_client/db/upgrade.php
+++ b/blocks/rss_client/db/upgrade.php
@@ -22,8 +22,6 @@
* @author Neill Magill
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade the block_rss_client database.
*
@@ -31,25 +29,6 @@
* @return boolean
*/
function xmldb_block_rss_client_upgrade($oldversion) {
- global $CFG, $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021121600) {
- // From Moodle 4.0, this block has been disabled by default in new installations.
- // If the site has no instances of this block, it will disabled during the upgrading process too.
- $totalcount = $DB->count_records('block_instances', ['blockname' => 'rss_client']);
- if ($totalcount == 0) {
- $DB->set_field('block', 'visible', 0, ['name' => 'rss_client']);
- }
-
- upgrade_block_savepoint(true, 2021121600, 'rss_client', false);
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/section_links/db/upgrade.php b/blocks/section_links/db/upgrade.php
index 02186906280cc..d177c32048a1c 100644
--- a/blocks/section_links/db/upgrade.php
+++ b/blocks/section_links/db/upgrade.php
@@ -37,8 +37,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the section links block.
*
@@ -47,14 +45,6 @@
* @param object $block
*/
function xmldb_block_section_links_upgrade($oldversion, $block) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/selfcompletion/db/upgrade.php b/blocks/selfcompletion/db/upgrade.php
index 58ba1b879a3b8..9fbb61b72aae1 100644
--- a/blocks/selfcompletion/db/upgrade.php
+++ b/blocks/selfcompletion/db/upgrade.php
@@ -37,8 +37,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Handles upgrading instances of this block.
*
@@ -46,25 +44,6 @@
* @param object $block
*/
function xmldb_block_selfcompletion_upgrade($oldversion, $block) {
- global $CFG, $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021121600) {
- // From Moodle 4.0, this block has been disabled by default in new installations.
- // If the site has no instances of this block, it will disabled during the upgrading process too.
- $totalcount = $DB->count_records('block_instances', ['blockname' => 'selfcompletion']);
- if ($totalcount == 0) {
- $DB->set_field('block', 'visible', 0, ['name' => 'selfcompletion']);
- }
-
- upgrade_block_savepoint(true, 2021121600, 'selfcompletion', false);
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/settings/db/upgrade.php b/blocks/settings/db/upgrade.php
index 271533b06e08b..6c8170dfbc44e 100644
--- a/blocks/settings/db/upgrade.php
+++ b/blocks/settings/db/upgrade.php
@@ -37,8 +37,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* As of the implementation of this block and the general navigation code
* in Moodle 2.0 the body of immediate upgrade work for this block and
@@ -53,14 +51,6 @@
* @param object $block
*/
function xmldb_block_settings_upgrade($oldversion, $block) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/tag_youtube/db/upgrade.php b/blocks/tag_youtube/db/upgrade.php
index c7cda7c048ee4..fc123c496f98a 100644
--- a/blocks/tag_youtube/db/upgrade.php
+++ b/blocks/tag_youtube/db/upgrade.php
@@ -22,119 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the Tag Youtube block.
*
* @param int $oldversion
*/
function xmldb_block_tag_youtube_upgrade($oldversion) {
- global $DB, $CFG, $OUTPUT;
-
- // Automatically generated Moodle v3.10.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
- // We need to fix every tag_youtube block instance that has used a legacy category name as a category config.
- // The category config needs to store the category ID instead.
-
- // If tag_youtube block instances exist.
- if ($blockinstances = $DB->get_records('block_instances', ['blockname' => 'tag_youtube'])) {
- $categories = [];
- // The block tag youtube needs to be configured and have a valid API key in order to obtain the video
- // category list.
- if ($apikey = get_config('block_tag_youtube', 'apikey')) {
- require_once($CFG->libdir . '/google/lib.php');
- $client = get_google_client();
- $client->setDeveloperKey($apikey);
- $client->setScopes(array(Google_Service_YouTube::YOUTUBE_READONLY));
- $service = new Google_Service_YouTube($client);
-
- try {
- // Get the video category list.
- $response = $service->videoCategories->listVideoCategories('snippet', ['regionCode' => 'us']);
-
- // Return an array of categories, where the key is the category name and the value is the
- // category ID.
- $categories = array_reduce($response['modelData']['items'], function ($categories, $category) {
- $categoryid = $category['id'];
- $categoryname = $category['snippet']['title'];
- // If videos can be associated with this category, add it to the categories list.
- if ($category['snippet']['assignable']) {
- $categories[$categoryname] = $categoryid;
- }
- return $categories;
- }, []);
- } catch (Exception $e) {
- $warn = "Due to the following error the youtube video categories were not obtained through the API:
- '{$e->getMessage()}'. Therefore, any legacy values used as a category setting in Tag Youtube
- block instances cannot be properly mapped and updated. All legacy values used as category setting
- will still be updated and set by default to 'Any category'.";
- echo $OUTPUT->notification($warn, 'notifyproblem');
- }
- } else {
- $warn = "The API key is missing in the Tag Youtube block configuration. Therefore, the youtube video
- categories cannot be obtained and mapped with the legacy values used as category setting. All legacy
- values used as category setting will still be updated and set by default to 'Any category'.";
- echo $OUTPUT->notification($warn, 'notifyproblem');
- }
-
- // Array that maps the old category names to the current category names.
- $categorynamemap = [
- 'Film' => 'Film & Animation',
- 'Autos' => 'Autos & Vehicles',
- 'Comedy' => 'Comedy',
- 'Entertainment' => 'Entertainment',
- 'Music' => 'Music',
- 'News' => 'News & Politics',
- 'People' => 'People & Blogs',
- 'Animals' => 'Pets & Animals',
- 'Howto' => 'Howto & Style',
- 'Sports' => 'Sports',
- 'Travel' => 'Travel & Events',
- 'Games' => 'Gaming',
- 'Education' => 'Education',
- 'Tech' => 'Tech'
- ];
-
- // If the block uses a legacy category name, update it to use the current category ID instead.
- foreach ($blockinstances as $blockinstance) {
- $blockconfig = unserialize(base64_decode($blockinstance->configdata));
-
- // Skip if the block does not have a specific category set.
- if (!isset($blockconfig->category)) {
- continue;
- }
-
- $blockcategoryconfig = $blockconfig->category;
- // The block is using a legacy category name as a category config.
- if (array_key_exists($blockcategoryconfig, $categorynamemap)) {
- if (!empty($categories)) { // The categories were successfully obtained through the API call.
- // Get the current category name.
- $currentcategoryname = $categorynamemap[$blockcategoryconfig];
- // Add the category ID as a new category config for this block instance.
- $blockconfig->category = $categories[$currentcategoryname];
- } else { // The categories were not obtained through the API call.
- // If the categories were not obtained through the API call, we are not able to map the
- // current legacy category name with the category ID. Therefore, we should default the category
- // config value to 0 ('Any category') to at least enable the block to function properly. The
- // user can later manually select the desired category and re-save the config through the UI.
- $blockconfig->category = 0;
- }
-
- $blockinstance->configdata = base64_encode(serialize($blockconfig));
- $DB->update_record('block_instances', $blockinstance);
- }
- }
- }
-
- upgrade_block_savepoint(true, 2021052501, 'tag_youtube', false);
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/blocks/timeline/db/upgrade.php b/blocks/timeline/db/upgrade.php
index e918fab526a1a..67a6be3dda829 100644
--- a/blocks/timeline/db/upgrade.php
+++ b/blocks/timeline/db/upgrade.php
@@ -36,35 +36,13 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
-require_once("{$CFG->libdir}/db/upgradelib.php");
-
/**
+ *
* Upgrade the timeline block
* @param int $oldversion
* @param object $block
*/
function xmldb_block_timeline_upgrade($oldversion, $block) {
- global $CFG, $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022030200) {
- // Update all timeline blocks in the my-index to be in the main content region.
- upgrade_block_set_defaultregion('timeline', '__default', 'my-index', 'content');
- upgrade_block_savepoint(true, 2022030200, 'timeline', false);
- }
-
- if ($oldversion < 2022041901) {
- upgrade_block_set_my_user_parent_context('timeline', '__default', 'my-index');
- upgrade_block_savepoint(true, 2022041901, 'timeline', false);
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/course/format/topics/db/upgrade.php b/course/format/topics/db/upgrade.php
index 5d1242b733066..4ff7f3130358d 100644
--- a/course/format/topics/db/upgrade.php
+++ b/course/format/topics/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade script for Topics course format.
*
@@ -31,14 +29,6 @@
* @return bool result
*/
function xmldb_format_topics_upgrade($oldversion) {
- global $CFG, $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/course/format/weeks/db/upgrade.php b/course/format/weeks/db/upgrade.php
index b437fe3eef379..4a2e225b715d9 100644
--- a/course/format/weeks/db/upgrade.php
+++ b/course/format/weeks/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade script for format_weeks
*
@@ -33,12 +31,6 @@
function xmldb_format_weeks_upgrade($oldversion) {
global $CFG, $DB;
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/enrol/database/db/upgrade.php b/enrol/database/db/upgrade.php
index 8dbae66351163..f9524cf264bf4 100644
--- a/enrol/database/db/upgrade.php
+++ b/enrol/database/db/upgrade.php
@@ -22,17 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_enrol_database_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/enrol/flatfile/db/upgrade.php b/enrol/flatfile/db/upgrade.php
index ad85c683432c9..b9183dd95dc55 100644
--- a/enrol/flatfile/db/upgrade.php
+++ b/enrol/flatfile/db/upgrade.php
@@ -22,17 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_enrol_flatfile_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/enrol/guest/db/upgrade.php b/enrol/guest/db/upgrade.php
index 84629fd61d3cb..11dba17306a85 100644
--- a/enrol/guest/db/upgrade.php
+++ b/enrol/guest/db/upgrade.php
@@ -22,17 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_enrol_guest_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/enrol/imsenterprise/db/upgrade.php b/enrol/imsenterprise/db/upgrade.php
index b28b3892f9469..cd60ea8e3b000 100644
--- a/enrol/imsenterprise/db/upgrade.php
+++ b/enrol/imsenterprise/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Performs upgrade of the database structure and data
*
@@ -31,14 +29,6 @@
* @return bool true
*/
function xmldb_enrol_imsenterprise_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/enrol/lti/db/upgrade.php b/enrol/lti/db/upgrade.php
index 479425f37ad67..81f71013fe137 100644
--- a/enrol/lti/db/upgrade.php
+++ b/enrol/lti/db/upgrade.php
@@ -23,8 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
- defined('MOODLE_INTERNAL') || die;
-
/**
* xmldb_lti_upgrade is the function that upgrades
* the lti module database when is needed
@@ -37,473 +35,6 @@
* @return boolean
*/
function xmldb_enrol_lti_upgrade($oldversion) {
- global $CFG, $OUTPUT, $DB;
- $dbman = $DB->get_manager();
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
- // LTI 1.3: Set a private key for this site (which is acting as a tool in LTI 1.3).
- require_once($CFG->dirroot . '/enrol/lti/upgradelib.php');
-
- $warning = enrol_lti_verify_private_key();
- if (!empty($warning)) {
- echo $OUTPUT->notification($warning, 'notifyproblem');
- }
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2021052501, 'enrol', 'lti');
- }
-
- if ($oldversion < 2021052502) {
- // Define table enrol_lti_app_registration to be created.
- $table = new xmldb_table('enrol_lti_app_registration');
-
- // Adding fields to table enrol_lti_app_registration.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('platformid', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('clientid', XMLDB_TYPE_CHAR, '1333', null, XMLDB_NOTNULL, null, null);
- $table->add_field('platformclienthash', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null);
- $table->add_field('authenticationrequesturl', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('jwksurl', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('accesstokenurl', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-
- // Adding keys to table enrol_lti_app_registration.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Add unique index on platformclienthash.
- $table->add_index('platformclienthash', XMLDB_INDEX_UNIQUE, ['platformclienthash']);
-
- // Conditionally launch create table for enrol_lti_app_registration.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2021052502, 'enrol', 'lti');
- }
-
- if ($oldversion < 2021052503) {
- // Add a new column 'ltiversion' to the enrol_lti_tools table.
- $table = new xmldb_table('enrol_lti_tools');
-
- // Define field ltiversion to be added to enrol_lti_tools.
- $field = new xmldb_field('ltiversion', XMLDB_TYPE_CHAR, 15, null, XMLDB_NOTNULL, null, "LTI-1p3", 'contextid');
-
- // Conditionally launch add field ltiversion, setting it to the legacy value for all published content.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- $DB->set_field('enrol_lti_tools', 'ltiversion', 'LTI-1p0/LTI-2p0');
- }
-
- // Define field uuid to be added to enrol_lti_tools.
- $field = new xmldb_field('uuid', XMLDB_TYPE_CHAR, 36, null, null, null, null, 'ltiversion');
-
- // Conditionally launch add field uuid, setting it to null for existing rows.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- $key = new xmldb_key('uuid', XMLDB_KEY_UNIQUE, ['uuid']);
- $dbman->add_key($table, $key);
- }
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2021052503, 'enrol', 'lti');
- }
-
- if ($oldversion < 2021052504) {
- // Define table enrol_lti_deployment to be created.
- $table = new xmldb_table('enrol_lti_deployment');
-
- // Adding fields to table enrol_lti_deployment.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('deploymentid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('platformid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-
- // Adding keys to table enrol_lti_deployment.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('platformid', XMLDB_KEY_FOREIGN, ['platformid'], 'enrol_lti_app_registration', ['id']);
-
- // Add unique index on platformid (issuer), deploymentid.
- $table->add_index('platformid-deploymentid', XMLDB_INDEX_UNIQUE, ['platformid', 'deploymentid']);
-
- // Conditionally launch create table for enrol_lti_deployment.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2021052504, 'enrol', 'lti');
- }
-
- if ($oldversion < 2021052505) {
- // Add a new column 'ltideploymentid' to the enrol_lti_users table.
- $table = new xmldb_table('enrol_lti_users');
-
- // Define field ltideploymentid to be added to enrol_lti_users.
- $field = new xmldb_field('ltideploymentid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'sourceid');
-
- // Conditionally launch add field deploymentid.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Launch add key ltideploymentid.
- $key = new xmldb_key('ltideploymentid', XMLDB_KEY_FOREIGN, ['ltideploymentid'], 'enrol_lti_deployment', ['id']);
- $dbman->add_key($table, $key);
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2021052505, 'enrol', 'lti');
- }
-
- if ($oldversion < 2021052506) {
- // Define table enrol_lti_resource_link to be created.
- $table = new xmldb_table('enrol_lti_resource_link');
-
- // Adding fields to table enrol_lti_resource_link.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('resourcelinkid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('resourceid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('ltideploymentid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('lticontextid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
- $table->add_field('lineitemsservice', XMLDB_TYPE_CHAR, '1333', null, null, null, null);
- $table->add_field('lineitemservice', XMLDB_TYPE_CHAR, '1333', null, null, null, null);
- $table->add_field('lineitemscope', XMLDB_TYPE_CHAR, '255', null, null, null, null);
- $table->add_field('resultscope', XMLDB_TYPE_CHAR, '255', null, null, null, null);
- $table->add_field('scorescope', XMLDB_TYPE_CHAR, '255', null, null, null, null);
- $table->add_field('contextmembershipsurl', XMLDB_TYPE_CHAR, '1333', null, null, null, null);
- $table->add_field('nrpsserviceversions', XMLDB_TYPE_CHAR, '255', null, null, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-
- // Adding keys to table enrol_lti_resource_link.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('ltideploymentid', XMLDB_KEY_FOREIGN, ['ltideploymentid'], 'enrol_lti_deployment', ['id']);
- $table->add_key('lticontextid', XMLDB_KEY_FOREIGN, ['lticontextid'], 'enrol_lti_context', ['id']);
-
- // Add unique index on resourcelinkid, ltideploymentid.
- $table->add_index('resourcelinkdid-ltideploymentid', XMLDB_INDEX_UNIQUE, ['resourcelinkid', 'ltideploymentid']);
-
- // Conditionally launch create table for enrol_lti_resource_link.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2021052506, 'enrol', 'lti');
- }
-
- if ($oldversion < 2021052507) {
- // Define table enrol_lti_context to be created.
- $table = new xmldb_table('enrol_lti_context');
-
- // Adding fields to table enrol_lti_context.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('contextid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('ltideploymentid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('type', XMLDB_TYPE_TEXT, null, null, null, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-
- // Adding keys to table enrol_lti_context.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('ltideploymentid', XMLDB_KEY_FOREIGN, ['ltideploymentid'], 'enrol_lti_deployment', ['id']);
-
- // Add unique index on ltideploymentid, contextid.
- $table->add_index('ltideploymentid-contextid', XMLDB_INDEX_UNIQUE, ['ltideploymentid', 'contextid']);
-
- // Conditionally launch create table for enrol_lti_context.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- upgrade_plugin_savepoint(true, 2021052507, 'enrol', 'lti');
- }
-
- if ($oldversion < 2021052508) {
- // Define table enrol_lti_user_resource_link to be created.
- $table = new xmldb_table('enrol_lti_user_resource_link');
-
- // Adding fields to table enrol_lti_user_resource_link.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('ltiuserid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('resourcelinkid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-
- // Adding keys to table enrol_lti_user_resource_link.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('ltiuserid', XMLDB_KEY_FOREIGN, ['ltiuserid'], 'enrol_lti_users', ['id']);
- $table->add_key('resourcelinkid', XMLDB_KEY_FOREIGN, ['resourcelinkid'], 'enrol_lti_resource_link', ['id']);
-
- // Add unique index on userid, resourcelinkid.
- $table->add_index('ltiuserid-resourcelinkid', XMLDB_INDEX_UNIQUE, ['ltiuserid', 'resourcelinkid']);
-
- // Conditionally launch create table for enrol_lti_user_resource_link.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
- upgrade_plugin_savepoint(true, 2021052508, 'enrol', 'lti');
- }
-
- if ($oldversion < 2021052512) {
- // Define field legacyconsumerkey to be added to enrol_lti_deployment.
- $table = new xmldb_table('enrol_lti_deployment');
- $field = new xmldb_field('legacyconsumerkey', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'platformid');
-
- // Conditionally launch add field legacyconsumerkey.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- upgrade_plugin_savepoint(true, 2021052512, 'enrol', 'lti');
- }
-
- if ($oldversion < 2021052513) {
- // Define table enrol_lti_reg_token to be created.
- $table = new xmldb_table('enrol_lti_reg_token');
-
- // Adding fields to table enrol_lti_reg_token.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('token', XMLDB_TYPE_CHAR, '60', null, XMLDB_NOTNULL, null, null);
- $table->add_field('expirytime', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-
- // Adding keys to table enrol_lti_reg_token.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Conditionally launch create table for enrol_lti_reg_token.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- upgrade_plugin_savepoint(true, 2021052513, 'enrol', 'lti');
- }
-
- if ($oldversion < 2021052514) {
- // Add a new column 'provisioningmodelearner' to the enrol_lti_tools table.
- $table = new xmldb_table('enrol_lti_tools');
-
- // Define field provisioningmodelearner to be added to enrol_lti_tools.
- $field = new xmldb_field('provisioningmodelearner', XMLDB_TYPE_INTEGER, 2, null, null, null, null, 'uuid');
-
- // Conditionally launch add field provisioningmodelearner.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field provisioningmodeinstructor to be added to enrol_lti_tools.
- $field = new xmldb_field('provisioningmodeinstructor', XMLDB_TYPE_INTEGER, 2, null, null, null, null,
- 'provisioningmodelearner');
-
- // Conditionally launch add field provisioningmodeinstructor.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2021052514, 'enrol', 'lti');
- }
-
- if ($oldversion < 2022031400) {
- // Changing the default of field platformid on table enrol_lti_app_registration to null.
- $table = new xmldb_table('enrol_lti_app_registration');
- $field = new xmldb_field('platformid', XMLDB_TYPE_TEXT, null, null, null, null, null, 'name');
-
- // Launch change of nullability for field platformid.
- $dbman->change_field_notnull($table, $field);
-
- // Changing the default of field clientid on table enrol_lti_app_registration to null.
- $field = new xmldb_field('clientid', XMLDB_TYPE_CHAR, '1333', null, null, null, null, 'platformid');
-
- // Launch change of nullability for field clientid.
- $dbman->change_field_notnull($table, $field);
-
- // Drop the platformclienthash index, so the field can be modified.
- $index = new xmldb_index('platformclienthash', XMLDB_INDEX_UNIQUE, ['platformclienthash']);
-
- // Conditionally launch drop index platformclienthash.
- if ($dbman->index_exists($table, $index)) {
- $dbman->drop_index($table, $index);
- }
-
- // Changing the default of field platformclienthash on table enrol_lti_app_registration to null.
- $field = new xmldb_field('platformclienthash', XMLDB_TYPE_CHAR, '64', null, null, null, null, 'clientid');
-
- // Launch change of nullability for field platformclienthash.
- $dbman->change_field_notnull($table, $field);
-
- // Recreate the platformclienthash index.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Changing the default of field authenticationrequesturl on table enrol_lti_app_registration to null.
- $field = new xmldb_field('authenticationrequesturl', XMLDB_TYPE_TEXT, null, null, null, null, null, 'platformclienthash');
-
- // Launch change of nullability for field authenticationrequesturl.
- $dbman->change_field_notnull($table, $field);
-
- // Changing the default of field jwksurl on table enrol_lti_app_registration to null.
- $field = new xmldb_field('jwksurl', XMLDB_TYPE_TEXT, null, null, null, null, null, 'authenticationrequesturl');
-
- // Launch change of nullability for field jwksurl.
- $dbman->change_field_notnull($table, $field);
-
- // Changing the default of field accesstokenurl on table enrol_lti_app_registration to null.
- $field = new xmldb_field('accesstokenurl', XMLDB_TYPE_TEXT, null, null, null, null, null, 'jwksurl');
-
- // Launch change of nullability for field accesstokenurl.
- $dbman->change_field_notnull($table, $field);
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2022031400, 'enrol', 'lti');
- }
-
- if ($oldversion < 2022031401) {
- // Define field uniqueid to be added to enrol_lti_app_registration (defined as null so it can be set for existing rows).
- $table = new xmldb_table('enrol_lti_app_registration');
- $field = new xmldb_field('uniqueid', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'accesstokenurl');
-
- // Conditionally launch add field uniqueid.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
-
- // Set existing values to use a suitable unique id.
- $recordset = $DB->get_recordset('enrol_lti_app_registration');
- foreach ($recordset as $record) {
- // Create a unique id for the registration. This will be used by:
- // a) The initiate_login endpoint (enrol/lti/login.php), as a stand in for client_id, when that's not provided.
- // b) The dynamic registration endpoint, where it'll be used to identify the incomplete registration to update
- // with the platform details.
- do {
- $bytes = random_bytes(30);
- $record->uniqueid = bin2hex($bytes);
- } while ($DB->record_exists('enrol_lti_app_registration', ['uniqueid' => $record->uniqueid]));
-
- $DB->update_record('enrol_lti_app_registration', $record);
- }
- $recordset->close();
-
- // Now make the field notnull.
- $field = new xmldb_field('uniqueid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'accesstokenurl');
- $dbman->change_field_notnull($table, $field);
- }
-
- // Launch add unique key uniqueid.
- $key = new xmldb_key('uniqueid', XMLDB_KEY_UNIQUE, ['uniqueid']);
- $dbman->add_key($table, $key);
-
- // Define field status to be added to enrol_lti_app_registration with a default value of 1 (to set existing rows).
- $field = new xmldb_field('status', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'uniqueid');
-
- // Conditionally launch add field status.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
-
- // Now change the default value to '0'.
- $field = new xmldb_field('status', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'uniqueid');
- $dbman->change_field_default($table, $field);
- }
-
- // Define field platformuniqueidhash to be added to enrol_lti_app_registration.
- $field = new xmldb_field('platformuniqueidhash', XMLDB_TYPE_CHAR, '64', null, null, null, null, 'status');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
-
- $recordset = $DB->get_recordset('enrol_lti_app_registration');
- foreach ($recordset as $record) {
- $record->platformuniqueidhash = hash('sha256', $record->platformid . ':' . $record->uniqueid);
- $DB->update_record('enrol_lti_app_registration', $record);
- }
- $recordset->close();
- }
-
- // Add index platformuniqueidhash to enrol_lti_app_registration.
- $index = new xmldb_index('platformuniqueidhash', XMLDB_INDEX_UNIQUE, ['platformuniqueidhash']);
-
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2022031401, 'enrol', 'lti');
- }
-
- if ($oldversion < 2022031402) {
- // Define table enrol_lti_reg_token to be dropped.
- $table = new xmldb_table('enrol_lti_reg_token');
-
- // Conditionally launch drop table for enrol_lti_reg_token.
- if ($dbman->table_exists($table)) {
- $dbman->drop_table($table);
- }
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2022031402, 'enrol', 'lti');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022061500) {
- // Disable all orphaned enrolment method instances.
- $sql = "id IN (SELECT t.enrolid
- FROM {enrol_lti_tools} t
- LEFT JOIN {context} c ON (t.contextid = c.id)
- WHERE c.id IS NULL)";
- $DB->set_field_select('enrol', 'status', 1, $sql);
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2022061500, 'enrol', 'lti');
- }
-
- if ($oldversion < 2022103100) {
- // Update lti user information for LTI 2.0 users having the wrong consumer secret recorded.
- // This applies to any LTI 2.0 user who has launched the tool (i.e. has lastaccess) and fixes a non-functional grade sync
- // for LTI 2.0 consumers.
- $sql = "SELECT lu.id, lc.secret
- FROM {enrol_lti_users} lu
- JOIN {enrol_lti_lti2_consumer} lc
- ON (" . $DB->sql_compare_text('lu.consumerkey', 255) . " = lc.consumerkey256)
- WHERE lc.ltiversion = :ltiversion
- AND " . $DB->sql_compare_text('lu.consumersecret') . " != lc.secret
- AND lu.lastaccess IS NOT NULL";
- $affectedltiusersrs = $DB->get_recordset_sql($sql, ['ltiversion' => 'LTI-2p0']);
- foreach ($affectedltiusersrs as $ltiuser) {
- $DB->set_field('enrol_lti_users', 'consumersecret', $ltiuser->secret, ['id' => $ltiuser->id]);
- }
- $affectedltiusersrs->close();
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2022103100, 'enrol', 'lti');
- }
-
- if ($oldversion < 2022110300) {
- // Update lti user information for any users missing a consumer secret.
- // This applies to any user who has launched the tool (i.e. has lastaccess) but who doesn't have a secret recorded.
- // This fixes a bug where enrol_lti_users records are created first during a member sync, and are missing the secret,
- // even despite having launched the tool subsequently.
- $sql = "SELECT lu.id, lc.secret
- FROM {enrol_lti_users} lu
- JOIN {enrol_lti_lti2_consumer} lc
- ON (" . $DB->sql_compare_text('lu.consumerkey', 255) . " = lc.consumerkey256)
- WHERE lu.consumersecret IS NULL
- AND lu.lastaccess IS NOT NULL";
- $affectedltiusersrs = $DB->get_recordset_sql($sql);
- foreach ($affectedltiusersrs as $ltiuser) {
- $DB->set_field('enrol_lti_users', 'consumersecret', $ltiuser->secret, ['id' => $ltiuser->id]);
- }
- $affectedltiusersrs->close();
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2022110300, 'enrol', 'lti');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/enrol/manual/db/upgrade.php b/enrol/manual/db/upgrade.php
index 73309cf308289..bfea1cc3a5a41 100644
--- a/enrol/manual/db/upgrade.php
+++ b/enrol/manual/db/upgrade.php
@@ -22,17 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_enrol_manual_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/enrol/mnet/db/upgrade.php b/enrol/mnet/db/upgrade.php
index c61dc76387196..3b69df6bd6160 100644
--- a/enrol/mnet/db/upgrade.php
+++ b/enrol/mnet/db/upgrade.php
@@ -22,17 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_enrol_mnet_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/enrol/paypal/db/upgrade.php b/enrol/paypal/db/upgrade.php
index 3ab4e879d7dbd..d715fbe791f5f 100644
--- a/enrol/paypal/db/upgrade.php
+++ b/enrol/paypal/db/upgrade.php
@@ -40,17 +40,7 @@
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_enrol_paypal_upgrade($oldversion) {
- global $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/enrol/self/db/upgrade.php b/enrol/self/db/upgrade.php
index 676e6d8e6be7c..f8677bd646aa3 100644
--- a/enrol/self/db/upgrade.php
+++ b/enrol/self/db/upgrade.php
@@ -22,17 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_enrol_self_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/filter/displayh5p/db/upgrade.php b/filter/displayh5p/db/upgrade.php
index 66dd5fe3fd80f..d9bf449e1acc8 100644
--- a/filter/displayh5p/db/upgrade.php
+++ b/filter/displayh5p/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* xmldb_filter_displayh5p_upgrade
*
@@ -31,14 +29,6 @@
* @return bool result
*/
function xmldb_filter_displayh5p_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/filter/mathjaxloader/db/upgrade.php b/filter/mathjaxloader/db/upgrade.php
index e218fa0b455d8..455007064de7e 100644
--- a/filter/mathjaxloader/db/upgrade.php
+++ b/filter/mathjaxloader/db/upgrade.php
@@ -22,33 +22,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_filter_mathjaxloader_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
- // Update CDN url.
- $originalurl = 'https://cdn.jsdelivr.net/npm/mathjax@2.7.8/MathJax.js';
- $newurl = 'https://cdn.jsdelivr.net/npm/mathjax@2.7.9/MathJax.js';
- $currenturl = get_config('filter_mathjaxloader', 'httpsurl');
- if ($currenturl == $originalurl) {
- set_config('httpsurl', $newurl, 'filter_mathjaxloader');
- }
-
- upgrade_plugin_savepoint(true, 2021052501, 'filter', 'mathjaxloader');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/filter/mediaplugin/db/upgrade.php b/filter/mediaplugin/db/upgrade.php
index 886671e91c886..1ca6b5811b0cf 100644
--- a/filter/mediaplugin/db/upgrade.php
+++ b/filter/mediaplugin/db/upgrade.php
@@ -23,21 +23,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_filter_mediaplugin_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/filter/tex/db/upgrade.php b/filter/tex/db/upgrade.php
index 2c12fd1469ba7..9db1ecd761c2b 100644
--- a/filter/tex/db/upgrade.php
+++ b/filter/tex/db/upgrade.php
@@ -23,21 +23,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_filter_tex_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/grade/grading/form/guide/db/upgrade.php b/grade/grading/form/guide/db/upgrade.php
index 2c176c94229de..fd45ed63af719 100644
--- a/grade/grading/form/guide/db/upgrade.php
+++ b/grade/grading/form/guide/db/upgrade.php
@@ -23,8 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Marking guide grading method upgrade task.
*
@@ -35,14 +33,6 @@
* @throws upgrade_exception
*/
function xmldb_gradingform_guide_upgrade($oldversion) {
- global $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/grade/grading/form/rubric/db/upgrade.php b/grade/grading/form/rubric/db/upgrade.php
index 72ba890372d79..999296542f6e8 100644
--- a/grade/grading/form/rubric/db/upgrade.php
+++ b/grade/grading/form/rubric/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Keeps track or rubric plugin upgrade path
*
@@ -31,14 +29,6 @@
* @return bool true
*/
function xmldb_gradingform_rubric_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/grade/report/grader/db/upgrade.php b/grade/report/grader/db/upgrade.php
index 2425f35a035d5..c0af003d6c112 100644
--- a/grade/report/grader/db/upgrade.php
+++ b/grade/report/grader/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade grader report.
*
diff --git a/grade/report/history/db/upgrade.php b/grade/report/history/db/upgrade.php
index 9a32ac563d6ab..26a444ced6bb0 100644
--- a/grade/report/history/db/upgrade.php
+++ b/grade/report/history/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade grade history report.
*
@@ -31,24 +29,6 @@
* @return bool result
*/
function xmldb_gradereport_history_upgrade($oldversion) {
-
- if ($oldversion < 2019111801) {
- $perpageconfig = get_config('moodle', 'grade_report_historyperpage');
-
- // For existing installations with a non-integer 'per page' config, update the value to the default.
- if (!empty($perpageconfig) && filter_var($perpageconfig, FILTER_VALIDATE_INT) === false) {
- set_config('grade_report_historyperpage', 50);
- }
-
- upgrade_plugin_savepoint(true, 2019111801, 'gradereport', 'history');
- }
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/grade/report/overview/db/upgrade.php b/grade/report/overview/db/upgrade.php
index 43fbd680738df..5df0e8e7b8a6e 100644
--- a/grade/report/overview/db/upgrade.php
+++ b/grade/report/overview/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade grade overview report.
*
@@ -31,13 +29,6 @@
* @return bool result
*/
function xmldb_gradereport_overview_upgrade($oldversion) {
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/grade/report/user/db/upgrade.php b/grade/report/user/db/upgrade.php
index 7a31e4fc28e5f..1cd616c3631ed 100644
--- a/grade/report/user/db/upgrade.php
+++ b/grade/report/user/db/upgrade.php
@@ -22,21 +22,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_gradereport_user_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/lib/antivirus/clamav/db/upgrade.php b/lib/antivirus/clamav/db/upgrade.php
index 2379691a80078..0d7b0d545b373 100644
--- a/lib/antivirus/clamav/db/upgrade.php
+++ b/lib/antivirus/clamav/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Run all ClamAV plugin upgrade steps between the current DB version and the current version on disk.
*
@@ -31,13 +29,6 @@
* @return bool
*/
function xmldb_antivirus_clamav_upgrade($oldversion) {
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index 0db681bcad0bc..b805206224c6a 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -40,2909 +40,69 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
-/**
- * Main upgrade tasks to be executed on Moodle version bump
- *
- * This function is automatically executed after one bump in the Moodle core
- * version is detected. It's in charge of performing the required tasks
- * to raise core from the previous version to the next one.
- *
- * It's a collection of ordered blocks of code, named "upgrade steps",
- * each one performing one isolated (from the rest of steps) task. Usually
- * tasks involve creating new DB objects or performing manipulation of the
- * information for cleanup/fixup purposes.
- *
- * Each upgrade step has a fixed structure, that can be summarised as follows:
- *
- * if ($oldversion < XXXXXXXXXX.XX) {
- * // Explanation of the update step, linking to issue in the Tracker if necessary
- * upgrade_set_timeout(XX); // Optional for big tasks
- * // Code to execute goes here, usually the XMLDB Editor will
- * // help you here. See {@link https://moodledev.io/general/development/tools/xmldb}.
- * upgrade_main_savepoint(true, XXXXXXXXXX.XX);
- * }
- *
- * All plugins within Moodle (modules, blocks, reports...) support the existence of
- * their own upgrade.php file, using the "Frankenstyle" component name as
- * defined at {@link https://moodledev.io/general/development/policies/codingstyle/frankenstyle}, for example:
- * - {@link xmldb_page_upgrade($oldversion)}. (modules don't require the plugintype ("mod_") to be used.
- * - {@link xmldb_auth_manual_upgrade($oldversion)}.
- * - {@link xmldb_workshopform_accumulative_upgrade($oldversion)}.
- * - ....
- *
- * In order to keep the contents of this file reduced, it's allowed to create some helper
- * functions to be used here in the {@link upgradelib.php} file at the same directory. Note
- * that such a file must be manually included from upgrade.php, and there are some restrictions
- * about what can be used within it.
- *
- * For more information, take a look to the documentation available:
- * - Data definition API: {@link https://moodledev.io/docs/apis/core/dml/ddl}
- * - Upgrade API: {@link https://moodledev.io/docs/guides/upgrade}
- *
- * @param int $oldversion
- * @return bool always true
- */
-function xmldb_main_upgrade($oldversion) {
- global $CFG, $DB;
-
- require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions.
-
- $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
-
- // Always keep this upgrade step with version being the minimum
- // allowed version to upgrade from (v3.11.8 right now).
- if ($oldversion < 2021051708) {
- // Just in case somebody hacks upgrade scripts or env, we really can not continue.
- echo("You need to upgrade to 3.11.8 or higher first!\n");
- exit(1);
- // Note this savepoint is 100% unreachable, but needed to pass the upgrade checks.
- upgrade_main_savepoint(true, 2021051708);
- }
-
- if ($oldversion < 2021052500.01) {
- // Delete all user evidence files from users that have been deleted.
- $sql = "SELECT DISTINCT f.*
- FROM {files} f
- LEFT JOIN {context} c ON f.contextid = c.id
- WHERE f.component = :component
- AND f.filearea = :filearea
- AND c.id IS NULL";
- $stalefiles = $DB->get_records_sql($sql, ['component' => 'core_competency', 'filearea' => 'userevidence']);
-
- $fs = get_file_storage();
- foreach ($stalefiles as $stalefile) {
- $fs->get_file_instance($stalefile)->delete();
- }
-
- upgrade_main_savepoint(true, 2021052500.01);
- }
-
- if ($oldversion < 2021052500.02) {
-
- // Define field timecreated to be added to task_adhoc.
- $table = new xmldb_table('task_adhoc');
- $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'blocking');
-
- // Conditionally launch add field timecreated.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.02);
- }
-
- if ($oldversion < 2021052500.04) {
- // Define field metadatasettings to be added to h5p_libraries.
- $table = new xmldb_table('h5p_libraries');
- $field = new xmldb_field('metadatasettings', XMLDB_TYPE_TEXT, null, null, null, null, null, 'coreminor');
-
- // Conditionally launch add field metadatasettings.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Get installed library files that have no metadata settings value.
- $params = [
- 'component' => 'core_h5p',
- 'filearea' => 'libraries',
- 'filename' => 'library.json',
- ];
- $sql = "SELECT l.id, f.id as fileid
- FROM {files} f
- LEFT JOIN {h5p_libraries} l ON f.itemid = l.id
- WHERE f.component = :component
- AND f.filearea = :filearea
- AND f.filename = :filename";
- $libraries = $DB->get_records_sql($sql, $params);
-
- // Update metadatasettings field when the attribute is present in the library.json file.
- $fs = get_file_storage();
- foreach ($libraries as $library) {
- $jsonfile = $fs->get_file_by_id($library->fileid);
- $jsoncontent = json_decode($jsonfile->get_content());
- if (isset($jsoncontent->metadataSettings)) {
- unset($library->fileid);
- $library->metadatasettings = json_encode($jsoncontent->metadataSettings);
- $DB->update_record('h5p_libraries', $library);
- }
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.04);
- }
-
- if ($oldversion < 2021052500.05) {
- // Define fields to be added to task_scheduled.
- $table = new xmldb_table('task_scheduled');
- $field = new xmldb_field('timestarted', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'disabled');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
- $field = new xmldb_field('hostname', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'timestarted');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
- $field = new xmldb_field('pid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'hostname');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define fields to be added to task_adhoc.
- $table = new xmldb_table('task_adhoc');
- $field = new xmldb_field('timestarted', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'blocking');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
- $field = new xmldb_field('hostname', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'timestarted');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
- $field = new xmldb_field('pid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'hostname');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define fields to be added to task_log.
- $table = new xmldb_table('task_log');
- $field = new xmldb_field('hostname', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'output');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
- $field = new xmldb_field('pid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'hostname');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.05);
- }
-
- if ($oldversion < 2021052500.06) {
- // Define table to store virus infected details.
- $table = new xmldb_table('infected_files');
-
- // Adding fields to table infected_files.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('filename', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('quarantinedfile', XMLDB_TYPE_TEXT, null, null, null, null, null);
- $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('reason', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table infected_files.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
-
- // Conditionally launch create table for infected_files.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
- upgrade_main_savepoint(true, 2021052500.06);
- }
-
- if ($oldversion < 2021052500.13) {
- // Remove all the files with component='core_h5p' and filearea='editor' because they won't be used anymore.
- $fs = get_file_storage();
- $syscontext = context_system::instance();
- $fs->delete_area_files($syscontext->id, 'core_h5p', 'editor');
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.13);
- }
-
- if ($oldversion < 2021052500.15) {
- // Copy From id captures the id of the source course when a new course originates from a restore
- // of another course on the same site.
- $table = new xmldb_table('course');
- $field = new xmldb_field('originalcourseid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
-
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.15);
- }
-
- if ($oldversion < 2021052500.19) {
- // Define table oauth2_refresh_token to be created.
- $table = new xmldb_table('oauth2_refresh_token');
-
- // Adding fields to table oauth2_refresh_token.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('issuerid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('token', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('scopehash', XMLDB_TYPE_CHAR, 40, null, XMLDB_NOTNULL, null, null);
-
- // Adding keys to table oauth2_refresh_token.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('issueridkey', XMLDB_KEY_FOREIGN, ['issuerid'], 'oauth2_issuer', ['id']);
- $table->add_key('useridkey', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
-
- // Adding indexes to table oauth2_refresh_token.
- $table->add_index('userid-issuerid-scopehash', XMLDB_INDEX_UNIQUE, array('userid', 'issuerid', 'scopehash'));
-
- // Conditionally launch create table for oauth2_refresh_token.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.19);
- }
-
- if ($oldversion < 2021052500.20) {
-
- // Define index modulename-instance-eventtype (not unique) to be added to event.
- $table = new xmldb_table('event');
- $index = new xmldb_index('modulename-instance-eventtype', XMLDB_INDEX_NOTUNIQUE, ['modulename', 'instance', 'eventtype']);
-
- // Conditionally launch add index modulename-instance-eventtype.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Define index modulename-instance (not unique) to be dropped form event.
- $table = new xmldb_table('event');
- $index = new xmldb_index('modulename-instance', XMLDB_INDEX_NOTUNIQUE, ['modulename', 'instance']);
-
- // Conditionally launch drop index modulename-instance.
- if ($dbman->index_exists($table, $index)) {
- $dbman->drop_index($table, $index);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.20);
- }
-
- if ($oldversion < 2021052500.24) {
- // Define fields tutorial and example to be added to h5p_libraries.
- $table = new xmldb_table('h5p_libraries');
-
- // Add tutorial field.
- $field = new xmldb_field('tutorial', XMLDB_TYPE_TEXT, null, null, null, null, null, 'metadatasettings');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Add example field.
- $field = new xmldb_field('example', XMLDB_TYPE_TEXT, null, null, null, null, null, 'tutorial');
-
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.24);
- }
-
- if ($oldversion < 2021052500.26) {
- // Delete orphaned course_modules_completion rows; these were not deleted properly
- // by remove_course_contents function.
- $DB->delete_records_select('course_modules_completion', "
- NOT EXISTS (
- SELECT 1
- FROM {course_modules} cm
- WHERE cm.id = {course_modules_completion}.coursemoduleid
- )");
- upgrade_main_savepoint(true, 2021052500.26);
- }
-
- if ($oldversion < 2021052500.27) {
- // Script to fix incorrect records of "hidden" field in existing grade items.
- $sql = "SELECT cm.instance, cm.course
- FROM {course_modules} cm
- JOIN {modules} m ON m.id = cm.module
- WHERE m.name = :module AND cm.visible = :visible";
- $hidequizlist = $DB->get_recordset_sql($sql, ['module' => 'quiz', 'visible' => 0]);
-
- foreach ($hidequizlist as $hidequiz) {
- $params = [
- 'itemmodule' => 'quiz',
- 'courseid' => $hidequiz->course,
- 'iteminstance' => $hidequiz->instance,
- ];
-
- $DB->set_field('grade_items', 'hidden', 1, $params);
- }
- $hidequizlist->close();
-
- upgrade_main_savepoint(true, 2021052500.27);
- }
-
- if ($oldversion < 2021052500.29) {
- // Get the current guest user which is also set as 'deleted'.
- $guestuser = $DB->get_record('user', ['id' => $CFG->siteguest, 'deleted' => 1]);
- // If there is a deleted guest user, reset the user to not be deleted and make sure the related
- // user context exists.
- if ($guestuser) {
- $guestuser->deleted = 0;
- $DB->update_record('user', $guestuser);
-
- // Get the guest user context.
- $guestusercontext = $DB->get_record('context',
- ['contextlevel' => CONTEXT_USER, 'instanceid' => $guestuser->id]);
-
- // If the guest user context does not exist, create it.
- if (!$guestusercontext) {
- $record = new stdClass();
- $record->contextlevel = CONTEXT_USER;
- $record->instanceid = $guestuser->id;
- $record->depth = 0;
- // The path is not known before insert.
- $record->path = null;
- $record->locked = 0;
-
- $record->id = $DB->insert_record('context', $record);
-
- // Update the path.
- $record->path = '/' . SYSCONTEXTID . '/' . $record->id;
- $record->depth = substr_count($record->path, '/');
- $DB->update_record('context', $record);
- }
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.29);
- }
-
- if ($oldversion < 2021052500.30) {
- // Reset analytics model output dir if it's the default value.
- $modeloutputdir = get_config('analytics', 'modeloutputdir');
- if (strcasecmp($modeloutputdir, $CFG->dataroot . DIRECTORY_SEPARATOR . 'models') == 0) {
- set_config('modeloutputdir', '', 'analytics');
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.30);
- }
-
- if ($oldversion < 2021052500.32) {
- // 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);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.32);
- }
-
- if ($oldversion < 2021052500.33) {
- $table = new xmldb_table('badge_backpack');
-
- // There is no key_exists, so test the equivalent index.
- $oldindex = new xmldb_index('backpackcredentials', XMLDB_KEY_UNIQUE, ['userid', 'externalbackpackid']);
- if (!$dbman->index_exists($table, $oldindex)) {
- // 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.
- $uniquekey = new xmldb_key('backpackcredentials', XMLDB_KEY_UNIQUE, ['userid', 'externalbackpackid']);
- $dbman->add_key($table, $uniquekey);
- }
-
- // 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)) {
- // 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);
- }
- }
-
- $dbman->drop_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.33);
- }
-
- if ($oldversion < 2021052500.36) {
- // Define table payment_accounts to be created.
- $table = new xmldb_table('payment_accounts');
-
- // Adding fields to table payment_accounts.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('idnumber', XMLDB_TYPE_CHAR, '100', null, null, null, null);
- $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('archived', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
-
- // Adding keys to table payment_accounts.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Conditionally launch create table for payment_accounts.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Define table payment_gateways to be created.
- $table = new xmldb_table('payment_gateways');
-
- // Adding fields to table payment_gateways.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('accountid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('gateway', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
- $table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1');
- $table->add_field('config', XMLDB_TYPE_TEXT, null, null, null, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-
- // Adding keys to table payment_gateways.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('accountid', XMLDB_KEY_FOREIGN, ['accountid'], 'payment_accounts', ['id']);
-
- // Conditionally launch create table for payment_gateways.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Define table payments to be created.
- $table = new xmldb_table('payments');
-
- // Adding fields to table payments.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('component', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
- $table->add_field('paymentarea', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null);
- $table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('amount', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null);
- $table->add_field('currency', XMLDB_TYPE_CHAR, '3', null, XMLDB_NOTNULL, null, null);
- $table->add_field('accountid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('gateway', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table payments.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
- $table->add_key('accountid', XMLDB_KEY_FOREIGN, ['accountid'], 'payment_accounts', ['id']);
-
- // Adding indexes to table payments.
- $table->add_index('gateway', XMLDB_INDEX_NOTUNIQUE, ['gateway']);
- $table->add_index('component-paymentarea-itemid', XMLDB_INDEX_NOTUNIQUE, ['component', 'paymentarea', 'itemid']);
-
- // Conditionally launch create table for payments.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.36);
- }
-
- if ($oldversion < 2021052500.42) {
- // Get all lessons that are set with a completion criteria of 'requires grade' but with no grade type set.
- $sql = "SELECT cm.id
- FROM {course_modules} cm
- JOIN {lesson} l ON l.id = cm.instance
- JOIN {modules} m ON m.id = cm.module
- WHERE m.name = :name AND cm.completiongradeitemnumber IS NOT NULL AND l.grade = :grade";
-
- do {
- if ($invalidconfigrations = $DB->get_records_sql($sql, ['name' => 'lesson', 'grade' => 0], 0, 1000)) {
- list($insql, $inparams) = $DB->get_in_or_equal(array_keys($invalidconfigrations), SQL_PARAMS_NAMED);
- $DB->set_field_select('course_modules', 'completiongradeitemnumber', null, "id $insql", $inparams);
- }
- } while ($invalidconfigrations);
-
- upgrade_main_savepoint(true, 2021052500.42);
- }
-
- if ($oldversion < 2021052500.55) {
- $DB->delete_records_select('event', "eventtype = 'category' AND categoryid = 0 AND userid <> 0");
-
- upgrade_main_savepoint(true, 2021052500.55);
- }
-
- if ($oldversion < 2021052500.59) {
- // Define field visibility to be added to contentbank_content.
- $table = new xmldb_table('contentbank_content');
- $field = new xmldb_field('visibility', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'contextid');
-
- // Conditionally launch add field visibility.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.59);
- }
-
- if ($oldversion < 2021052500.60) {
-
- // We are going to remove the field 'hidepicture' from the groups
- // so we need to remove the pictures from those groups. But we prevent
- // the execution twice because this could be executed again when upgrading
- // to different versions.
- if ($dbman->field_exists('groups', 'hidepicture')) {
-
- $sql = "SELECT g.id, g.courseid, ctx.id AS contextid
- FROM {groups} g
- JOIN {context} ctx
- ON ctx.instanceid = g.courseid
- AND ctx.contextlevel = :contextlevel
- WHERE g.hidepicture = 1";
-
- // Selecting all the groups that have hide picture enabled, and organising them by context.
- $groupctx = [];
- $records = $DB->get_recordset_sql($sql, ['contextlevel' => CONTEXT_COURSE]);
- foreach ($records as $record) {
- if (!isset($groupctx[$record->contextid])) {
- $groupctx[$record->contextid] = [];
- }
- $groupctx[$record->contextid][] = $record->id;
- }
- $records->close();
-
- // Deleting the group files.
- $fs = get_file_storage();
- foreach ($groupctx as $contextid => $groupids) {
- list($in, $inparams) = $DB->get_in_or_equal($groupids, SQL_PARAMS_NAMED);
- $fs->delete_area_files_select($contextid, 'group', 'icon', $in, $inparams);
- }
-
- // Updating the database to remove picture from all those groups.
- $sql = "UPDATE {groups} SET picture = :pic WHERE hidepicture = :hide";
- $DB->execute($sql, ['pic' => 0, 'hide' => 1]);
- }
-
- // Define field hidepicture to be dropped from groups.
- $table = new xmldb_table('groups');
- $field = new xmldb_field('hidepicture');
-
- // Conditionally launch drop field hidepicture.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.60);
- }
-
- if ($oldversion < 2021052500.64) {
- // Get all the external backpacks and update the sortorder column, to avoid repeated/wrong values. As sortorder was not
- // used since now, the id column will be the criteria to follow for re-ordering them with a valid value.
- $i = 1;
- $records = $DB->get_records('badge_external_backpack', null, 'id ASC');
- foreach ($records as $record) {
- $record->sortorder = $i++;
- $DB->update_record('badge_external_backpack', $record);
- }
-
- upgrade_main_savepoint(true, 2021052500.64);
- }
-
- if ($oldversion < 2021052500.67) {
- // The $CFG->badges_site_backpack setting has been removed because it's not required anymore. From now, the default backpack
- // will be the one with lower sortorder value.
- unset_config('badges_site_backpack');
-
- upgrade_main_savepoint(true, 2021052500.67);
- }
-
- if ($oldversion < 2021052500.69) {
-
- // Define field type to be added to oauth2_issuer.
- $table = new xmldb_table('oauth2_issuer');
- $field = new xmldb_field('servicetype', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'requireconfirmation');
-
- // Conditionally launch add field type.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Set existing values to the proper servicetype value.
- // It's not critical if the servicetype column doesn't contain the proper value for Google, Microsoft, Facebook or
- // Nextcloud services because, for now, this value is used for services using different discovery method.
- // However, let's try to upgrade it using the default value for the baseurl or image. If any of these default values
- // have been changed, the servicetype column will remain NULL.
- $recordset = $DB->get_recordset('oauth2_issuer');
- foreach ($recordset as $record) {
- if ($record->baseurl == 'https://accounts.google.com/') {
- $record->servicetype = 'google';
- $DB->update_record('oauth2_issuer', $record);
- } else if ($record->image == 'https://www.microsoft.com/favicon.ico') {
- $record->servicetype = 'microsoft';
- $DB->update_record('oauth2_issuer', $record);
- } else if ($record->image == 'https://facebookbrand.com/wp-content/uploads/2016/05/flogo_rgb_hex-brc-site-250.png') {
- $record->servicetype = 'facebook';
- $DB->update_record('oauth2_issuer', $record);
- } else if ($record->image == 'https://nextcloud.com/wp-content/themes/next/assets/img/common/favicon.png?x16328') {
- $record->servicetype = 'nextcloud';
- $DB->update_record('oauth2_issuer', $record);
- }
- }
- $recordset->close();
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.69);
- }
-
- if ($oldversion < 2021052500.74) {
- // Define field 'showactivitydates' to be added to course table.
- $table = new xmldb_table('course');
- $field = new xmldb_field('showactivitydates', XMLDB_TYPE_INTEGER, '1', null,
- XMLDB_NOTNULL, null, '0', 'originalcourseid');
-
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.74);
- }
-
- if ($oldversion < 2021052500.75) {
- // Define field 'showcompletionconditions' to be added to course.
- $table = new xmldb_table('course');
- $field = new xmldb_field('showcompletionconditions', XMLDB_TYPE_INTEGER, '1', null,
- XMLDB_NOTNULL, null, '1', 'completionnotify');
-
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.75);
- }
-
- if ($oldversion < 2021052500.78) {
-
- // Define field enabled to be added to h5p_libraries.
- $table = new xmldb_table('h5p_libraries');
- $field = new xmldb_field('enabled', XMLDB_TYPE_INTEGER, '1', null, null, null, '1', 'example');
-
- // Conditionally launch add field enabled.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.78);
- }
-
- if ($oldversion < 2021052500.83) {
-
- // Define field loginpagename to be added to oauth2_issuer.
- $table = new xmldb_table('oauth2_issuer');
- $field = new xmldb_field('loginpagename', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'servicetype');
-
- // Conditionally launch add field loginpagename.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.83);
- }
-
- if ($oldversion < 2021052500.84) {
- require_once($CFG->dirroot . '/user/profile/field/social/upgradelib.php');
- $table = new xmldb_table('user');
- $tablecolumns = ['icq', 'skype', 'aim', 'yahoo', 'msn', 'url'];
-
- foreach ($tablecolumns as $column) {
- $field = new xmldb_field($column);
- if ($dbman->field_exists($table, $field)) {
- user_profile_social_moveto_profilefield($column);
- $dbman->drop_field($table, $field);
- }
- }
-
- // Update all module availability if it relies on the old user fields.
- user_profile_social_update_module_availability();
-
- // Remove field mapping for oauth2.
- $DB->delete_records('oauth2_user_field_mapping', array('internalfield' => 'url'));
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.84);
- }
-
- if ($oldversion < 2021052500.85) {
- require_once($CFG->libdir . '/db/upgradelib.php');
-
- // Check if this site has executed the problematic upgrade steps.
- $needsfixing = upgrade_calendar_site_status(false);
-
- // Only queue the task if this site has been affected by the problematic upgrade step.
- if ($needsfixing) {
-
- // Create adhoc task to search and recover orphaned calendar events.
- $record = new \stdClass();
- $record->classname = '\core\task\calendar_fix_orphaned_events';
-
- // Next run time based from nextruntime computation in \core\task\manager::queue_adhoc_task().
- $nextruntime = time() - 1;
- $record->nextruntime = $nextruntime;
- $DB->insert_record('task_adhoc', $record);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.85);
- }
-
- if ($oldversion < 2021052500.87) {
- // Changing the default of field showcompletionconditions on table course to 0.
- $table = new xmldb_table('course');
- $field = new xmldb_field('showcompletionconditions', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'showactivitydates');
-
- // Launch change of nullability for field showcompletionconditions.
- $dbman->change_field_notnull($table, $field);
-
- // Launch change of default for field showcompletionconditions.
- $dbman->change_field_default($table, $field);
-
- // Set showcompletionconditions to null for courses which don't track completion.
- $sql = "UPDATE {course}
- SET showcompletionconditions = null
- WHERE enablecompletion <> 1";
- $DB->execute($sql);
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.87);
- }
-
- if ($oldversion < 2021052500.90) {
- // Remove usemodchooser user preference for every user.
- $DB->delete_records('user_preferences', ['name' => 'usemodchooser']);
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021052500.90);
- }
-
- if ($oldversion < 2021060200.00) {
-
- // Define index name (not unique) to be added to user_preferences.
- $table = new xmldb_table('user_preferences');
- $index = new xmldb_index('name', XMLDB_INDEX_NOTUNIQUE, ['name']);
-
- // Conditionally launch add index name.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021060200.00);
- }
-
- if ($oldversion < 2021060900.00) {
- // Update the externalfield to be larger.
- $table = new xmldb_table('oauth2_user_field_mapping');
- $field = new xmldb_field('externalfield', XMLDB_TYPE_CHAR, '500', null, XMLDB_NOTNULL, false, null, 'issuerid');
- $dbman->change_field_type($table, $field);
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021060900.00);
- }
-
- if ($oldversion < 2021072800.01) {
- // Define table reportbuilder_report to be created.
- $table = new xmldb_table('reportbuilder_report');
-
- // Adding fields to table reportbuilder_report.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('source', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('type', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('component', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
- $table->add_field('area', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
- $table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('usercreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table reportbuilder_report.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('usercreated', XMLDB_KEY_FOREIGN, ['usercreated'], 'user', ['id']);
- $table->add_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
- $table->add_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']);
-
- // Conditionally launch create table for reportbuilder_report.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021072800.01);
- }
-
- if ($oldversion < 2021090200.01) {
- // Remove qformat_webct (unless it has manually been added back).
- if (!file_exists($CFG->dirroot . '/question/format/webct/format.php')) {
- unset_all_config_for_plugin('qformat_webct');
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021090200.01);
- }
-
- if ($oldversion < 2021091100.01) {
- // If message_jabber is no longer present, remove it.
- if (!file_exists($CFG->dirroot . '/message/output/jabber/message_output_jabber.php')) {
- // Remove Jabber from the notification plugins list.
- $DB->delete_records('message_processors', ['name' => 'jabber']);
-
- // Remove user preference settings.
- $DB->delete_records('user_preferences', ['name' => 'message_processor_jabber_jabberid']);
- $sql = 'SELECT *
- FROM {user_preferences} up
- WHERE ' . $DB->sql_like('up.name', ':name', false, false) . ' AND ' .
- $DB->sql_like('up.value', ':value', false, false);
- $params = [
- 'name' => 'message_provider_%',
- 'value' => '%jabber%',
- ];
- $jabbersettings = $DB->get_recordset_sql($sql, $params);
- foreach ($jabbersettings as $jabbersetting) {
- // Remove 'jabber' from the value.
- $jabbersetting->value = implode(',', array_diff(explode(',', $jabbersetting->value), ['jabber']));
- $DB->update_record('user_preferences', $jabbersetting);
- }
- $jabbersettings->close();
-
- // Clean config settings.
- unset_config('jabberhost');
- unset_config('jabberserver');
- unset_config('jabberusername');
- unset_config('jabberpassword');
- unset_config('jabberport');
-
- // Remove default notification preferences.
- $like = $DB->sql_like('name', '?', true, true, false, '|');
- $params = [$DB->sql_like_escape('jabber_provider_', '|') . '%'];
- $DB->delete_records_select('config_plugins', $like, $params);
-
- // Clean config config settings.
- unset_all_config_for_plugin('message_jabber');
- }
-
- upgrade_main_savepoint(true, 2021091100.01);
- }
-
- if ($oldversion < 2021091100.02) {
- // Set the description field to HTML format for the Default course category.
- $category = $DB->get_record('course_categories', ['id' => 1]);
-
- if (!empty($category) && $category->descriptionformat == FORMAT_MOODLE) {
- // Format should be changed only if it's still set to FORMAT_MOODLE.
- if (!is_null($category->description)) {
- // If description is not empty, format the content to HTML.
- $category->description = format_text($category->description, FORMAT_MOODLE);
- }
- $category->descriptionformat = FORMAT_HTML;
- $DB->update_record('course_categories', $category);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021091100.02);
- }
-
- if ($oldversion < 2021091700.01) {
- // Default 'off' for existing sites as this is the behaviour they had earlier.
- set_config('enroladminnewcourse', false);
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021091700.01);
- }
-
- if ($oldversion < 2021091700.02) {
- // If portfolio_picasa is no longer present, remove it.
- if (!file_exists($CFG->dirroot . '/portfolio/picasa/version.php')) {
- $instance = $DB->get_record('portfolio_instance', ['plugin' => 'picasa']);
- if (!empty($instance)) {
- // Remove all records from portfolio_instance_config.
- $DB->delete_records('portfolio_instance_config', ['instance' => $instance->id]);
- // Remove all records from portfolio_instance_user.
- $DB->delete_records('portfolio_instance_user', ['instance' => $instance->id]);
- // Remove all records from portfolio_log.
- $DB->delete_records('portfolio_log', ['portfolio' => $instance->id]);
- // Remove all records from portfolio_tempdata.
- $DB->delete_records('portfolio_tempdata', ['instance' => $instance->id]);
- // Remove the record from the portfolio_instance table.
- $DB->delete_records('portfolio_instance', ['id' => $instance->id]);
- }
-
- // Clean config.
- unset_all_config_for_plugin('portfolio_picasa');
- }
-
- upgrade_main_savepoint(true, 2021091700.02);
- }
-
- if ($oldversion < 2021091700.03) {
- // If repository_picasa is no longer present, remove it.
- if (!file_exists($CFG->dirroot . '/repository/picasa/version.php')) {
- $instance = $DB->get_record('repository', ['type' => 'picasa']);
- if (!empty($instance)) {
- // Remove all records from repository_instance_config table.
- $DB->delete_records('repository_instance_config', ['instanceid' => $instance->id]);
- // Remove all records from repository_instances table.
- $DB->delete_records('repository_instances', ['typeid' => $instance->id]);
- // Remove the record from the repository table.
- $DB->delete_records('repository', ['id' => $instance->id]);
- }
-
- // Clean config.
- unset_all_config_for_plugin('picasa');
-
- // Remove orphaned files.
- upgrade_delete_orphaned_file_records();
- }
-
- upgrade_main_savepoint(true, 2021091700.03);
- }
-
- if ($oldversion < 2021091700.04) {
- // Remove media_swf (unless it has manually been added back).
- if (!file_exists($CFG->dirroot . '/media/player/swf/classes/plugin.php')) {
- unset_all_config_for_plugin('media_swf');
- }
-
- upgrade_main_savepoint(true, 2021091700.04);
- }
-
- if ($oldversion < 2021092400.01) {
- // If tool_health is no longer present, remove it.
- if (!file_exists($CFG->dirroot . '/admin/tool/health/version.php')) {
- // Clean config.
- unset_all_config_for_plugin('tool_health');
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021092400.01);
- }
-
- if ($oldversion < 2021092400.03) {
- // Remove repository_picasa configuration (unless it has manually been added back).
- if (!file_exists($CFG->dirroot . '/repository/picasa/version.php')) {
- unset_all_config_for_plugin('repository_picasa');
- }
-
- upgrade_main_savepoint(true, 2021092400.03);
- }
-
- if ($oldversion < 2021100300.01) {
- // Remove repository_skydrive (unless it has manually been added back).
- if (!file_exists($CFG->dirroot . '/repository/skydrive/lib.php')) {
- unset_all_config_for_plugin('repository_skydrive');
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021100300.01);
- }
-
- if ($oldversion < 2021100300.02) {
- // Remove filter_censor (unless it has manually been added back).
- if (!file_exists($CFG->dirroot . '/filter/censor/filter.php')) {
- unset_all_config_for_plugin('filter_censor');
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021100300.02);
- }
-
- if ($oldversion < 2021100600.01) {
- // Remove qformat_examview (unless it has manually been added back).
- if (!file_exists($CFG->dirroot . '/question/format/examview/format.php')) {
- unset_all_config_for_plugin('qformat_examview');
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021100600.01);
- }
-
- if ($oldversion < 2021100600.02) {
- $table = new xmldb_table('course_completion_defaults');
-
- // Adding fields to table course_completion_defaults.
- $field = new xmldb_field('completionpassgrade', XMLDB_TYPE_INTEGER, '1', null,
- XMLDB_NOTNULL, null, '0', 'completionusegrade');
-
- // Conditionally launch add field for course_completion_defaults.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- upgrade_main_savepoint(true, 2021100600.02);
- }
-
- if ($oldversion < 2021100600.03) {
- $table = new xmldb_table('course_modules');
-
- // Adding new fields to table course_module table.
- $field = new xmldb_field('completionpassgrade', XMLDB_TYPE_INTEGER, '1', null,
- XMLDB_NOTNULL, null, '0', 'completionexpected');
- // Conditionally launch create table for course_completion_defaults.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- upgrade_main_savepoint(true, 2021100600.03);
- }
-
- if ($oldversion < 2021100600.04) {
- // Define index itemtype-mod-inst-course (not unique) to be added to grade_items.
- $table = new xmldb_table('grade_items');
- $index = new xmldb_index('itemtype-mod-inst-course', XMLDB_INDEX_NOTUNIQUE,
- ['itemtype', 'itemmodule', 'iteminstance', 'courseid']);
-
- // Conditionally launch add index itemtype-mod-inst-course.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021100600.04);
- }
-
- if ($oldversion < 2021101900.01) {
- $table = new xmldb_table('reportbuilder_report');
-
- // Define field name to be added to reportbuilder_report.
- $field = new xmldb_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'id');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field conditiondata to be added to reportbuilder_report.
- $field = new xmldb_field('conditiondata', XMLDB_TYPE_TEXT, null, null, null, null, null, 'type');
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define table reportbuilder_column to be created.
- $table = new xmldb_table('reportbuilder_column');
-
- // Adding fields to table reportbuilder_column.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('reportid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('uniqueidentifier', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('aggregation', XMLDB_TYPE_CHAR, '32', null, null, null, null);
- $table->add_field('heading', XMLDB_TYPE_CHAR, '255', null, null, null, null);
- $table->add_field('columnorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('sortenabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('sortdirection', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null);
- $table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
- $table->add_field('usercreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table reportbuilder_column.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('reportid', XMLDB_KEY_FOREIGN, ['reportid'], 'reportbuilder_report', ['id']);
- $table->add_key('usercreated', XMLDB_KEY_FOREIGN, ['usercreated'], 'user', ['id']);
- $table->add_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
-
- // Conditionally launch create table for reportbuilder_column.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Define table reportbuilder_filter to be created.
- $table = new xmldb_table('reportbuilder_filter');
-
- // Adding fields to table reportbuilder_filter.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('reportid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('uniqueidentifier', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('heading', XMLDB_TYPE_CHAR, '255', null, null, null, null);
- $table->add_field('iscondition', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('filterorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('usercreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table reportbuilder_filter.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('reportid', XMLDB_KEY_FOREIGN, ['reportid'], 'reportbuilder_report', ['id']);
- $table->add_key('usercreated', XMLDB_KEY_FOREIGN, ['usercreated'], 'user', ['id']);
- $table->add_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
-
- // Conditionally launch create table for reportbuilder_filter.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021101900.01);
- }
-
- if ($oldversion < 2021102600.01) {
- // Remove block_quiz_results (unless it has manually been added back).
- if (!file_exists($CFG->dirroot . '/blocks/quiz_result/block_quiz_results.php')) {
- // Delete instances.
- $instances = $DB->get_records_list('block_instances', 'blockname', ['quiz_results']);
- $instanceids = array_keys($instances);
-
- if (!empty($instanceids)) {
- blocks_delete_instances($instanceids);
- }
-
- // Delete the block from the block table.
- $DB->delete_records('block', array('name' => 'quiz_results'));
-
- // Remove capabilities.
- capabilities_cleanup('block_quiz_results');
- // Clean config.
- unset_all_config_for_plugin('block_quiz_results');
-
- // Remove Moodle-level quiz_results based capabilities.
- $capabilitiestoberemoved = ['block/quiz_results:addinstance'];
- // Delete any role_capabilities for the old roles.
- $DB->delete_records_list('role_capabilities', 'capability', $capabilitiestoberemoved);
- // Delete the capability itself.
- $DB->delete_records_list('capabilities', 'name', $capabilitiestoberemoved);
- }
-
- upgrade_main_savepoint(true, 2021102600.01);
- }
-
- if ($oldversion < 2021102900.02) {
- // If portfolio_boxnet is no longer present, remove it.
- if (!file_exists($CFG->dirroot . '/portfolio/boxnet/version.php')) {
- $instance = $DB->get_record('portfolio_instance', ['plugin' => 'boxnet']);
- if (!empty($instance)) {
- // Remove all records from portfolio_instance_config.
- $DB->delete_records('portfolio_instance_config', ['instance' => $instance->id]);
- // Remove all records from portfolio_instance_user.
- $DB->delete_records('portfolio_instance_user', ['instance' => $instance->id]);
- // Remove all records from portfolio_log.
- $DB->delete_records('portfolio_log', ['portfolio' => $instance->id]);
- // Remove all records from portfolio_tempdata.
- $DB->delete_records('portfolio_tempdata', ['instance' => $instance->id]);
- // Remove the record from the portfolio_instance table.
- $DB->delete_records('portfolio_instance', ['id' => $instance->id]);
- }
-
- // Clean config.
- unset_all_config_for_plugin('portfolio_boxnet');
- }
-
- // If repository_boxnet is no longer present, remove it.
- if (!file_exists($CFG->dirroot . '/repository/boxnet/version.php')) {
- $instance = $DB->get_record('repository', ['type' => 'boxnet']);
- if (!empty($instance)) {
- // Remove all records from repository_instance_config table.
- $DB->delete_records('repository_instance_config', ['instanceid' => $instance->id]);
- // Remove all records from repository_instances table.
- $DB->delete_records('repository_instances', ['typeid' => $instance->id]);
- // Remove the record from the repository table.
- $DB->delete_records('repository', ['id' => $instance->id]);
- }
-
- // Clean config.
- unset_all_config_for_plugin('repository_boxnet');
-
- // The boxnet repository plugin stores some config in 'boxnet' incorrectly.
- unset_all_config_for_plugin('boxnet');
-
- // Remove orphaned files.
- upgrade_delete_orphaned_file_records();
- }
-
- upgrade_main_savepoint(true, 2021102900.02);
- }
-
- if ($oldversion < 2021110100.00) {
-
- // Define table reportbuilder_audience to be created.
- $table = new xmldb_table('reportbuilder_audience');
-
- // Adding fields to table reportbuilder_audience.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('reportid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('classname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('configdata', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('usercreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table reportbuilder_audience.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('reportid', XMLDB_KEY_FOREIGN, ['reportid'], 'reportbuilder_report', ['id']);
- $table->add_key('usercreated', XMLDB_KEY_FOREIGN, ['usercreated'], 'user', ['id']);
- $table->add_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
-
- // Conditionally launch create table for reportbuilder_audience.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021110100.00);
- }
-
- if ($oldversion < 2021110800.02) {
- // Define a field 'downloadcontent' in the 'course_modules' table.
- $table = new xmldb_table('course_modules');
- $field = new xmldb_field('downloadcontent', XMLDB_TYPE_INTEGER, '1', null, null, null, 1, 'deletioninprogress');
-
- // Conditionally launch add field 'downloadcontent'.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021110800.02);
- }
-
- if ($oldversion < 2021110800.03) {
-
- // Define field settingsdata to be added to reportbuilder_report.
- $table = new xmldb_table('reportbuilder_report');
- $field = new xmldb_field('settingsdata', XMLDB_TYPE_TEXT, null, null, null, null, null, 'conditiondata');
-
- // Conditionally launch add field settingsdata.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021110800.03);
- }
-
- if ($oldversion < 2021111700.00) {
- $mycoursespage = new stdClass();
- $mycoursespage->userid = null;
- $mycoursespage->name = '__courses';
- $mycoursespage->private = 0;
- $mycoursespage->sortorder = 0;
- $DB->insert_record('my_pages', $mycoursespage);
-
- upgrade_main_savepoint(true, 2021111700.00);
- }
-
- if ($oldversion < 2021111700.01) {
-
- // Define field uniquerows to be added to reportbuilder_report.
- $table = new xmldb_table('reportbuilder_report');
- $field = new xmldb_field('uniquerows', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'type');
-
- // Conditionally launch add field uniquerows.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021111700.01);
- }
-
- if ($oldversion < 2021120100.01) {
-
- // Get current configuration data.
- $currentcustomusermenuitems = str_replace(["\r\n", "\r"], "\n", $CFG->customusermenuitems);
- $lines = explode("\n", $currentcustomusermenuitems);
- $lines = array_map('trim', $lines);
- $calendarcustomusermenu = 'calendar,core_calendar|/calendar/view.php?view=month|i/calendar';
-
- if (!in_array($calendarcustomusermenu, $lines)) {
- // Add Calendar item to the menu.
- array_splice($lines, 1, 0, [$calendarcustomusermenu]);
- set_config('customusermenuitems', implode("\n", $lines));
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021120100.01);
- }
-
- if ($oldversion < 2021121400.01) {
- // The $CFG->grade_navmethod setting has been removed because it's not required anymore. This setting was used
- // to set the type of navigation (tabs or dropdown box) which will be displayed in gradebook. However, these
- // navigation methods are no longer used and replaced with tertiary navigation.
- unset_config('grade_navmethod');
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021121400.01);
- }
-
- if ($oldversion < 2021121700.01) {
- // Get current support email setting value.
- $config = get_config('moodle', 'supportemail');
-
- // Check if support email setting is empty and then set it to null.
- // We must do that so the setting is displayed during the upgrade.
- if (empty($config)) {
- set_config('supportemail', null);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021121700.01);
- }
-
- if ($oldversion < 2021122100.00) {
- // Get current configuration data.
- $currentcustomusermenuitems = str_replace(["\r\n", "\r"], "\n", $CFG->customusermenuitems);
-
- // The old default customusermenuitems config for 3.11 and below.
- $oldcustomusermenuitems = 'grades,grades|/grade/report/mygrades.php|t/grades
-calendar,core_calendar|/calendar/view.php?view=month|i/calendar
-messages,message|/message/index.php|t/message
-preferences,moodle|/user/preferences.php|t/preferences';
-
- // Check if the current customusermenuitems config matches the old customusermenuitems config.
- $samecustomusermenuitems = $currentcustomusermenuitems == $oldcustomusermenuitems;
- if ($samecustomusermenuitems) {
- // If the site is still using the old defaults, upgrade to the new default.
- $newcustomusermenuitems = 'profile,moodle|/user/profile.php
-grades,grades|/grade/report/mygrades.php
-calendar,core_calendar|/calendar/view.php?view=month
-privatefiles,moodle|/user/files.php';
- // Set the new configuration back.
- set_config('customusermenuitems', $newcustomusermenuitems);
- } else {
- // If the site is not using the old defaults, only add necessary entries.
- $lines = preg_split('/\n/', $currentcustomusermenuitems, -1, PREG_SPLIT_NO_EMPTY);
- $lines = array_map(static function(string $line): string {
- // Previous format was "|[|]" - pix icon is no longer supported.
- $lineparts = explode('|', trim($line), 3);
- // Return first two parts of line.
- return implode('|', array_slice($lineparts, 0, 2));
- }, $lines);
-
- // Remove the Preference entry from the menu to prevent duplication
- // since it will be added again in user_get_user_navigation_info().
- $lines = array_filter($lines, function($value) {
- return strpos($value, 'preferences,moodle|/user/preferences.php') === false;
- });
-
- $matches = preg_grep('/\|\/user\/files.php/i', $lines);
- if (!$matches) {
- // Add the Private files entry to the menu.
- $lines[] = 'privatefiles,moodle|/user/files.php';
- }
-
- $matches = preg_grep('/\|\/user\/profile.php/i', $lines);
- if (!$matches) {
- // Add the Profile entry to top of the menu.
- array_unshift($lines, 'profile,moodle|/user/profile.php');
- }
-
- // Set the new configuration back.
- set_config('customusermenuitems', implode("\n", $lines));
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021122100.00);
- }
-
-
- if ($oldversion < 2021122100.01) {
-
- // Define field heading to be added to reportbuilder_audience.
- $table = new xmldb_table('reportbuilder_audience');
- $field = new xmldb_field('heading', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'reportid');
-
- // Conditionally launch add field heading.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021122100.01);
- }
-
- if ($oldversion < 2021122100.02) {
-
- // Define table reportbuilder_schedule to be created.
- $table = new xmldb_table('reportbuilder_schedule');
-
- // Adding fields to table reportbuilder_schedule.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('reportid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1');
- $table->add_field('audiences', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('format', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('subject', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('message', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('messageformat', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('userviewas', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timescheduled', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('recurrence', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('reportempty', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timelastsent', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timenextsend', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('usercreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table reportbuilder_schedule.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('reportid', XMLDB_KEY_FOREIGN, ['reportid'], 'reportbuilder_report', ['id']);
- $table->add_key('userviewas', XMLDB_KEY_FOREIGN, ['userviewas'], 'user', ['id']);
- $table->add_key('usercreated', XMLDB_KEY_FOREIGN, ['usercreated'], 'user', ['id']);
- $table->add_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
-
- // Conditionally launch create table for reportbuilder_schedule.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021122100.02);
- }
-
- if ($oldversion < 2021123000.01) {
- // The tool_admin_presets tables have been moved to core, because core_adminpresets component has been created, so
- // it can interact with the rest of core.
- // So the tool_admin_presetsXXX tables will be renamed to adminipresetsXXX if they exists; otherwise, they will be created.
-
- $tooltable = new xmldb_table('tool_admin_presets');
- $table = new xmldb_table('adminpresets');
- if ($dbman->table_exists($tooltable)) {
- $dbman->rename_table($tooltable, 'adminpresets');
- } else if (!$dbman->table_exists($table)) {
- // Adding fields to table adminpresets.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('comments', XMLDB_TYPE_TEXT, null, null, null, null, null);
- $table->add_field('site', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('author', XMLDB_TYPE_CHAR, '255', null, null, null, null);
- $table->add_field('moodleversion', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null);
- $table->add_field('moodlerelease', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
- $table->add_field('iscore', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timeimported', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table adminpresets.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Launch create table for adminpresets.
- $dbman->create_table($table);
- }
-
- $tooltable = new xmldb_table('tool_admin_presets_it');
- $table = new xmldb_table('adminpresets_it');
- if ($dbman->table_exists($tooltable)) {
- $dbman->rename_table($tooltable, 'adminpresets_it');
- } else if (!$dbman->table_exists($table)) {
- // Adding fields to table adminpresets_it.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('adminpresetid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
- $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
- $table->add_field('value', XMLDB_TYPE_TEXT, null, null, null, null, null);
-
- // Adding keys to table adminpresets_it.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Adding indexes to table adminpresets_it.
- $table->add_index('adminpresetid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetid']);
-
- // Launch create table for adminpresets_it.
- $dbman->create_table($table);
- }
-
- $tooltable = new xmldb_table('tool_admin_presets_it_a');
- $table = new xmldb_table('adminpresets_it_a');
- if ($dbman->table_exists($tooltable)) {
- $dbman->rename_table($tooltable, 'adminpresets_it_a');
- } else if (!$dbman->table_exists($table)) {
- // Adding fields to table adminpresets_it_a.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
- $table->add_field('value', XMLDB_TYPE_TEXT, null, null, null, null, null);
-
- // Adding keys to table adminpresets_it_a.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Adding indexes to table adminpresets_it_a.
- $table->add_index('itemid', XMLDB_INDEX_NOTUNIQUE, ['itemid']);
-
- // Launch create table for adminpresets_it_a.
- $dbman->create_table($table);
- }
-
- $tooltable = new xmldb_table('tool_admin_presets_app');
- $table = new xmldb_table('adminpresets_app');
- if ($dbman->table_exists($tooltable)) {
- $dbman->rename_table($tooltable, 'adminpresets_app');
- } else if (!$dbman->table_exists($table)) {
- // Adding fields to table adminpresets_app.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('adminpresetid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('time', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-
- // Adding keys to table adminpresets_app.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Adding indexes to table adminpresets_app.
- $table->add_index('adminpresetid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetid']);
-
- // Launch create table for adminpresets_app.
- $dbman->create_table($table);
- }
-
- $tooltable = new xmldb_table('tool_admin_presets_app_it');
- $table = new xmldb_table('adminpresets_app_it');
- if ($dbman->table_exists($tooltable)) {
- $dbman->rename_table($tooltable, 'adminpresets_app_it');
- } else if (!$dbman->table_exists($table)) {
- // Adding fields to table adminpresets_app_it.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('adminpresetapplyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('configlogid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-
- // Adding keys to table adminpresets_app_it.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Adding indexes to table adminpresets_app_it.
- $table->add_index('configlogid', XMLDB_INDEX_NOTUNIQUE, ['configlogid']);
- $table->add_index('adminpresetapplyid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetapplyid']);
-
- // Launch create table for adminpresets_app_it.
- $dbman->create_table($table);
- }
-
- $tooltable = new xmldb_table('tool_admin_presets_app_it_a');
- $table = new xmldb_table('adminpresets_app_it_a');
- if ($dbman->table_exists($tooltable)) {
- $dbman->rename_table($tooltable, 'adminpresets_app_it_a');
- } else if (!$dbman->table_exists($table)) {
- // Adding fields to table adminpresets_app_it_a.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('adminpresetapplyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('configlogid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('itemname', XMLDB_TYPE_CHAR, '100', null, null, null, null);
-
- // Adding keys to table adminpresets_app_it_a.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Adding indexes to table adminpresets_app_it_a.
- $table->add_index('configlogid', XMLDB_INDEX_NOTUNIQUE, ['configlogid']);
- $table->add_index('adminpresetapplyid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetapplyid']);
-
- // Launch create table for adminpresets_app_it_a.
- $dbman->create_table($table);
- }
-
- $tooltable = new xmldb_table('tool_admin_presets_plug');
- $table = new xmldb_table('adminpresets_plug');
- if ($dbman->table_exists($tooltable)) {
- $dbman->rename_table($tooltable, 'adminpresets_plug');
- } else if (!$dbman->table_exists($table)) {
- // Adding fields to table adminpresets_plug.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('adminpresetid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
- $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
- $table->add_field('enabled', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table adminpresets_plug.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Adding indexes to table adminpresets_plug.
- $table->add_index('adminpresetid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetid']);
-
- // Launch create table for adminpresets_plug.
- $dbman->create_table($table);
- }
-
- $tooltable = new xmldb_table('tool_admin_presets_app_plug');
- $table = new xmldb_table('adminpresets_app_plug');
- if ($dbman->table_exists($tooltable)) {
- $dbman->rename_table($tooltable, 'adminpresets_app_plug');
- } else if (!$dbman->table_exists($table)) {
- // Adding fields to table adminpresets_app_plug.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('adminpresetapplyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
- $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
- $table->add_field('value', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('oldvalue', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table adminpresets_app_plug.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Adding indexes to table adminpresets_app_plug.
- $table->add_index('adminpresetapplyid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetapplyid']);
-
- // Launch create table for adminpresets_app_plug.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
- }
-
- if ($DB->count_records('adminpresets', ['iscore' => 1]) == 0) {
- // Create default core site admin presets.
- require_once($CFG->dirroot . '/admin/presets/classes/helper.php');
- \core_adminpresets\helper::create_default_presets();
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021123000.01);
- }
-
- if ($oldversion < 2021123000.02) {
- // If exists, migrate sensiblesettings admin settings from tool_admin_preset to adminpresets.
- if (get_config('tool_admin_presets', 'sensiblesettings') !== false) {
- set_config('sensiblesettings', get_config('tool_admin_presets', 'sensiblesettings'), 'adminpresets');
- unset_config('sensiblesettings', 'tool_admin_presets');
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021123000.02);
- }
-
- if ($oldversion < 2021123000.03) {
- // If exists, migrate lastpresetapplied setting from tool_admin_preset to adminpresets.
- if (get_config('tool_admin_presets', 'lastpresetapplied') !== false) {
- set_config('lastpresetapplied', get_config('tool_admin_presets', 'lastpresetapplied'), 'adminpresets');
- unset_config('lastpresetapplied', 'tool_admin_presets');
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2021123000.03);
- }
-
- if ($oldversion < 2022011100.01) {
- // The following blocks have been hidden by default, so they shouldn't be enabled in the Full core preset: Course/site
- // summary, RSS feeds, Self completion and Feedback.
- $params = ['name' => get_string('fullpreset', 'core_adminpresets')];
- $fullpreset = $DB->get_record_select('adminpresets', 'name = :name and iscore > 0', $params);
-
- if (!$fullpreset) {
- // Full admin preset might have been created using the English name.
- $name = get_string_manager()->get_string('fullpreset', 'core_adminpresets', null, 'en');
- $params['name'] = $name;
- $fullpreset = $DB->get_record_select('adminpresets', 'name = :name and iscore > 0', $params);
- }
- if (!$fullpreset) {
- // We tried, but we didn't find full by name. Let's find a core preset that sets 'usecomments' setting to 1.
- $sql = "SELECT preset.*
- FROM {adminpresets} preset
- INNER JOIN {adminpresets_it} it ON preset.id = it.adminpresetid
- WHERE it.name = :name AND it.value = :value AND preset.iscore > 0";
- $params = ['name' => 'usecomments', 'value' => '1'];
- $fullpreset = $DB->get_record_sql($sql, $params);
- }
-
- if ($fullpreset) {
- $blocknames = ['course_summary', 'feedback', 'rss_client', 'selfcompletion'];
- list($blocksinsql, $blocksinparams) = $DB->get_in_or_equal($blocknames);
-
- // Remove entries from the adminpresets_app_plug table (in case the preset has been applied).
- $appliedpresets = $DB->get_records('adminpresets_app', ['adminpresetid' => $fullpreset->id], '', 'id');
- if ($appliedpresets) {
- list($appsinsql, $appsinparams) = $DB->get_in_or_equal(array_keys($appliedpresets));
- $sql = "adminpresetapplyid $appsinsql AND plugin='block' AND name $blocksinsql";
- $params = array_merge($appsinparams, $blocksinparams);
- $DB->delete_records_select('adminpresets_app_plug', $sql, $params);
- }
-
- // Remove entries for these blocks from the adminpresets_plug table.
- $sql = "adminpresetid = ? AND plugin='block' AND name $blocksinsql";
- $params = array_merge([$fullpreset->id], $blocksinparams);
- $DB->delete_records_select('adminpresets_plug', $sql, $params);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022011100.01);
- }
-
- if ($oldversion < 2022012100.02) {
- // Migrate default message output config.
- $preferences = get_config('message');
-
- $treatedprefs = [];
-
- foreach ($preferences as $preference => $value) {
- // Extract provider and preference name from the setting name.
- // Example name: airnotifier_provider_enrol_imsenterprise_imsenterprise_enrolment_permitted
- // Provider: airnotifier
- // Preference: enrol_imsenterprise_imsenterprise_enrolment_permitted.
- $providerparts = explode('_provider_', $preference);
- if (count($providerparts) <= 1) {
- continue;
- }
-
- $provider = $providerparts[0];
- $preference = $providerparts[1];
-
- // Extract and remove last part of the preference previously extracted: ie. permitted.
- $parts = explode('_', $preference);
- $key = array_pop($parts);
-
- if (in_array($key, ['permitted', 'loggedin', 'loggedoff'])) {
- if ($key == 'permitted') {
- // We will use provider name instead of permitted.
- $key = $provider;
- } else {
- // Logged in and logged off values are a csv of the enabled providers.
- $value = explode(',', $value);
- }
-
- // Join the rest of the parts: ie enrol_imsenterprise_imsenterprise_enrolment.
- $prefname = implode('_', $parts);
-
- if (!isset($treatedprefs[$prefname])) {
- $treatedprefs[$prefname] = [];
- }
-
- // Save the value with the selected key.
- $treatedprefs[$prefname][$key] = $value;
- }
- }
-
- // Now take every preference previous treated and its values.
- foreach ($treatedprefs as $prefname => $values) {
- $enabled = []; // List of providers enabled for each preference.
-
- // Enable if one of those is enabled.
- $loggedin = isset($values['loggedin']) ? $values['loggedin'] : [];
- foreach ($loggedin as $provider) {
- $enabled[$provider] = 1;
- }
- $loggedoff = isset($values['loggedoff']) ? $values['loggedoff'] : [];
- foreach ($loggedoff as $provider) {
- $enabled[$provider] = 1;
- }
-
- // Do not treat those values again.
- unset($values['loggedin']);
- unset($values['loggedoff']);
-
- // Translate rest of values coming from permitted "key".
- foreach ($values as $provider => $value) {
- $locked = false;
-
- switch ($value) {
- case 'forced':
- // Provider is enabled by force.
- $enabled[$provider] = 1;
- $locked = true;
- break;
- case 'disallowed':
- // Provider is disabled by force.
- unset($enabled[$provider]);
- $locked = true;
- break;
- default:
- // Provider is not forced (permitted) or invalid values.
- }
-
- // Save locked.
- if ($locked) {
- set_config($provider.'_provider_'.$prefname.'_locked', 1, 'message');
- } else {
- set_config($provider.'_provider_'.$prefname.'_locked', 0, 'message');
- }
- // Remove old value.
- unset_config($provider.'_provider_'.$prefname.'_permitted', 'message');
- }
-
- // Save the new values.
- $value = implode(',', array_keys($enabled));
- set_config('message_provider_'.$prefname.'_enabled', $value, 'message');
- // Remove old values.
- unset_config('message_provider_'.$prefname.'_loggedin', 'message');
- unset_config('message_provider_'.$prefname.'_loggedoff', 'message');
- }
-
- // Migrate user preferences. ie merging message_provider_moodle_instantmessage_loggedoff with
- // message_provider_moodle_instantmessage_loggedin to message_provider_moodle_instantmessage_enabled.
-
- $allrecordsloggedoff = $DB->sql_like('name', ':loggedoff');
- $total = $DB->count_records_select(
- 'user_preferences',
- $allrecordsloggedoff,
- ['loggedoff' => 'message_provider_%_loggedoff']
- );
- $i = 0;
- if ($total == 0) {
- $total = 1; // Avoid division by zero.
- }
-
- // Show a progress bar.
- $pbar = new progress_bar('upgradeusernotificationpreferences', 500, true);
- $pbar->update($i, $total, "Upgrading user notifications preferences - $i/$total.");
-
- // We're migrating provider per provider to reduce memory usage.
- $providers = $DB->get_records('message_providers', null, 'name');
- foreach ($providers as $provider) {
- // 60 minutes to migrate each provider.
- upgrade_set_timeout(3600);
- $componentproviderbase = 'message_provider_'.$provider->component.'_'.$provider->name;
-
- $loggedinname = $componentproviderbase.'_loggedin';
- $loggedoffname = $componentproviderbase.'_loggedoff';
-
- // Change loggedin to enabled.
- $enabledname = $componentproviderbase.'_enabled';
- $DB->set_field('user_preferences', 'name', $enabledname, ['name' => $loggedinname]);
-
- $selectparams = [
- 'enabled' => $enabledname,
- 'loggedoff' => $loggedoffname,
- ];
- $sql = 'SELECT m1.id loggedoffid, m1.value as loggedoff, m2.value as enabled, m2.id as enabledid
- FROM
- (SELECT id, userid, value FROM {user_preferences} WHERE name = :loggedoff) m1
- LEFT JOIN
- (SELECT id, userid, value FROM {user_preferences} WHERE name = :enabled) m2
- ON m1.userid = m2.userid';
-
- while (($rs = $DB->get_recordset_sql($sql, $selectparams, 0, 1000)) && $rs->valid()) {
- // 10 minutes for every chunk.
- upgrade_set_timeout(600);
-
- $deleterecords = [];
- $changename = [];
- $changevalue = []; // Multidimensional array with possible values as key to reduce SQL queries.
- foreach ($rs as $record) {
- if (empty($record->enabledid)) {
- // Enabled does not exists, change the name.
- $changename[] = $record->loggedoffid;
- } else if ($record->enabledid != $record->loggedoff) {
- // Exist and values differ (checked on SQL), update the enabled record.
-
- if ($record->enabled != 'none' && !empty($record->enabled)) {
- $enabledvalues = explode(',', $record->enabled);
- } else {
- $enabledvalues = [];
- }
-
- if ($record->loggedoff != 'none' && !empty($record->loggedoff)) {
- $loggedoffvalues = explode(',', $record->loggedoff);
- } else {
- $loggedoffvalues = [];
- }
-
- $values = array_unique(array_merge($enabledvalues, $loggedoffvalues));
- sort($values);
-
- $newvalue = empty($values) ? 'none' : implode(',', $values);
- if (!isset($changevalue[$newvalue])) {
- $changevalue[$newvalue] = [];
- }
- $changevalue[$newvalue][] = $record->enabledid;
-
- $deleterecords[] = $record->loggedoffid;
- } else {
- // They are the same, just delete loggedoff one.
- $deleterecords[] = $record->loggedoffid;
- }
- $i++;
- }
- $rs->close();
-
- // Commit the changes.
- if (!empty($changename)) {
- $changenameparams = [
- 'name' => $loggedoffname,
- ];
- $changenameselect = 'name = :name AND id IN (' . implode(',', $changename) . ')';
- $DB->set_field_select('user_preferences', 'name', $enabledname, $changenameselect, $changenameparams);
- }
-
- if (!empty($changevalue)) {
- $changevalueparams = [
- 'name' => $enabledname,
- ];
- foreach ($changevalue as $value => $ids) {
- $changevalueselect = 'name = :name AND id IN (' . implode(',', $ids) . ')';
- $DB->set_field_select('user_preferences', 'value', $value, $changevalueselect, $changevalueparams);
- }
- }
-
- if (!empty($deleterecords)) {
- $deleteparams = [
- 'name' => $loggedoffname,
- ];
- $deleteselect = 'name = :name AND id IN (' . implode(',', $deleterecords) . ')';
- $DB->delete_records_select('user_preferences', $deleteselect, $deleteparams);
- }
-
- // Update progress.
- $pbar->update($i, $total, "Upgrading user notifications preferences - $i/$total.");
- }
- $rs->close();
-
- // Delete the rest of loggedoff values (that are equal than enabled).
- $deleteparams = [
- 'name' => $loggedoffname,
- ];
- $deleteselect = 'name = :name';
- $i += $DB->count_records_select('user_preferences', $deleteselect, $deleteparams);
- $DB->delete_records_select('user_preferences', $deleteselect, $deleteparams);
-
- // Update progress.
- $pbar->update($i, $total, "Upgrading user notifications preferences - $i/$total.");
- }
-
- core_plugin_manager::reset_caches();
-
- // Delete the orphan records.
- $allrecordsparams = ['loggedin' => 'message_provider_%_loggedin', 'loggedoff' => 'message_provider_%_loggedoff'];
- $allrecordsloggedin = $DB->sql_like('name', ':loggedin');
- $allrecordsloggedinoffsql = "$allrecordsloggedin OR $allrecordsloggedoff";
- $DB->delete_records_select('user_preferences', $allrecordsloggedinoffsql, $allrecordsparams);
-
- // Update progress.
- $pbar->update($total, $total, "Upgrading user notifications preferences - $total/$total.");
-
- upgrade_main_savepoint(true, 2022012100.02);
- }
-
- // Introduce question versioning to core.
- // First, create the new tables.
- if ($oldversion < 2022020200.01) {
- // Define table question_bank_entries to be created.
- $table = new xmldb_table('question_bank_entries');
-
- // Adding fields to table question_bank_entries.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('questioncategoryid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0);
- $table->add_field('idnumber', XMLDB_TYPE_CHAR, '100', null, null, null, null);
- $table->add_field('ownerid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
-
- // Adding keys to table question_bank_entries.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('questioncategoryid', XMLDB_KEY_FOREIGN, ['questioncategoryid'], 'question_categories', ['id']);
- $table->add_key('ownerid', XMLDB_KEY_FOREIGN, ['ownerid'], 'user', ['id']);
-
- // Conditionally launch create table for question_bank_entries.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Create category id and id number index.
- $index = new xmldb_index('categoryidnumber', XMLDB_INDEX_UNIQUE, ['questioncategoryid', 'idnumber']);
-
- // Conditionally launch add index categoryidnumber.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Define table question_versions to be created.
- $table = new xmldb_table('question_versions');
-
- // Adding fields to table question_versions.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('questionbankentryid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0);
- $table->add_field('version', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 1);
- $table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0);
- $table->add_field('status', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, 'ready');
-
- // Adding keys to table question_versions.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('questionbankentryid', XMLDB_KEY_FOREIGN, ['questionbankentryid'], 'question_bank_entries', ['id']);
- $table->add_key('questionid', XMLDB_KEY_FOREIGN, ['questionid'], 'question', ['id']);
-
- // Conditionally launch create table for question_versions.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Define table question_references to be created.
- $table = new xmldb_table('question_references');
-
- // Adding fields to table question_references.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('usingcontextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0);
- $table->add_field('component', XMLDB_TYPE_CHAR, '100', null, null, null, null);
- $table->add_field('questionarea', XMLDB_TYPE_CHAR, '50', null, null, null, null);
- $table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
- $table->add_field('questionbankentryid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0);
- $table->add_field('version', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
-
- // Adding keys to table question_references.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('usingcontextid', XMLDB_KEY_FOREIGN, ['usingcontextid'], 'context', ['id']);
- $table->add_key('questionbankentryid', XMLDB_KEY_FOREIGN, ['questionbankentryid'], 'question_bank_entries', ['id']);
-
- // Conditionally launch create table for question_references.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Define table question_set_references to be created.
- $table = new xmldb_table('question_set_references');
-
- // Adding fields to table question_set_references.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('usingcontextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0);
- $table->add_field('component', XMLDB_TYPE_CHAR, '100', null, null, null, null);
- $table->add_field('questionarea', XMLDB_TYPE_CHAR, '50', null, null, null, null);
- $table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
- $table->add_field('questionscontextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0);
- $table->add_field('filtercondition', XMLDB_TYPE_TEXT, null, null, null, null, null);
-
- // Adding keys to table question_set_references.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('usingcontextid', XMLDB_KEY_FOREIGN, ['usingcontextid'], 'context', ['id']);
- $table->add_key('questionscontextid', XMLDB_KEY_FOREIGN, ['questionscontextid'], 'context', ['id']);
-
- // Conditionally launch create table for question_set_references.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022020200.01);
- }
-
- if ($oldversion < 2022020200.02) {
- // Define a new temporary field in the question_bank_entries tables.
- // Creating temporary field questionid to populate the data in question version table.
- // This will make sure the appropriate question id is inserted the version table without making any complex joins.
- $table = new xmldb_table('question_bank_entries');
- $field = new xmldb_field('questionid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- $transaction = $DB->start_delegated_transaction();
- upgrade_set_timeout(3600);
- // Create the data for the question_bank_entries table with, including the new temporary field.
- $sql = <<execute($sql);
-
- $transaction->allow_commit();
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022020200.02);
- }
-
- if ($oldversion < 2022020200.03) {
- $transaction = $DB->start_delegated_transaction();
- upgrade_set_timeout(3600);
- // Create the question_versions using that temporary field.
- $sql = << 0 THEN 'hidden'
- ELSE 'ready'
- END
- FROM {question_bank_entries} qbe
- INNER JOIN {question} q ON qbe.questionid = q.id
- EOF;
-
- // Inserting question_versions data.
- $DB->execute($sql);
-
- $transaction->allow_commit();
-
- // Dropping temporary field questionid.
- $table = new xmldb_table('question_bank_entries');
- $field = new xmldb_field('questionid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022020200.03);
- }
-
- if ($oldversion < 2022020200.04) {
- $transaction = $DB->start_delegated_transaction();
- upgrade_set_timeout(3600);
- // Create the base data for the random questions in the set_references table.
- // This covers most of the hard work in one go.
- $concat = $DB->sql_concat("'{\"questioncategoryid\":\"'", 'q.category', "'\",\"includingsubcategories\":\"'",
- 'qs.includingsubcategories', "'\"}'");
- $sql = <<execute($sql, [
- 'quizmoduleid' => $DB->get_field('modules', 'id', ['name' => 'quiz']),
- 'contextmodule' => CONTEXT_MODULE,
- 'random' => 'random',
- ]);
-
- $transaction->allow_commit();
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022020200.04);
- }
-
- if ($oldversion < 2022020200.05) {
- $transaction = $DB->start_delegated_transaction();
- upgrade_set_timeout(3600);
-
- // Count all the slot tags to be migrated (for progress bar).
- $total = $DB->count_records('quiz_slot_tags');
- $pbar = new progress_bar('migratequestiontags', 1000, true);
- $i = 0;
- // Updating slot_tags for random question tags.
- // Now fetch any quiz slot tags and update those slot details into the question_set_references.
- $slottags = $DB->get_recordset('quiz_slot_tags', [], 'slotid ASC');
-
- $tagstrings = [];
- $lastslot = null;
- $runinsert = function (int $lastslot, array $tagstrings) use ($DB) {
- $conditiondata = $DB->get_field('question_set_references', 'filtercondition',
- ['itemid' => $lastslot, 'component' => 'mod_quiz', 'questionarea' => 'slot']);
-
- // It is possible to have leftover tags in the database, without a corresponding
- // slot, because of an old bugs (e.g. MDL-76193). Therefore, if the slot is not found,
- // we can safely discard these tags.
- if (!empty($conditiondata)) {
- $condition = json_decode($conditiondata);
- $condition->tags = $tagstrings;
- $DB->set_field('question_set_references', 'filtercondition', json_encode($condition),
- ['itemid' => $lastslot, 'component' => 'mod_quiz', 'questionarea' => 'slot']);
- }
- };
-
- foreach ($slottags as $tag) {
- upgrade_set_timeout(3600);
- if ($lastslot && $tag->slotid != $lastslot) {
- if (!empty($tagstrings)) {
- // Insert the data.
- $runinsert($lastslot, $tagstrings);
- }
- // Prepare for the next slot id.
- $tagstrings = [];
- }
-
- $lastslot = $tag->slotid;
- $tagstrings[] = "{$tag->tagid},{$tag->tagname}";
- // Update progress.
- $i++;
- $pbar->update($i, $total, "Migrating question tags - $i/$total.");
- }
- if ($tagstrings) {
- $runinsert($lastslot, $tagstrings);
- }
- $slottags->close();
-
- $transaction->allow_commit();
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022020200.05);
- }
-
- if ($oldversion < 2022020200.06) {
- $transaction = $DB->start_delegated_transaction();
- upgrade_set_timeout(3600);
- // Create question_references record for each question.
- // Except if qtype is random. That case is handled by question_set_reference.
- $sql = "INSERT INTO {question_references}
- (usingcontextid, component, questionarea, itemid, questionbankentryid)
- SELECT c.id, 'mod_quiz', 'slot', qs.id, qv.questionbankentryid
- FROM {question} q
- JOIN {question_versions} qv ON q.id = qv.questionid
- JOIN {quiz_slots} qs ON q.id = qs.questionid
- JOIN {modules} m ON m.name = 'quiz'
- JOIN {course_modules} cm ON cm.module = m.id AND cm.instance = qs.quizid
- JOIN {context} c ON c.instanceid = cm.id AND c.contextlevel = " . CONTEXT_MODULE . "
- WHERE q.qtype <> 'random'";
-
- // Inserting question_references data.
- $DB->execute($sql);
-
- $transaction->allow_commit();
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022020200.06);
- }
-
- // Finally, drop fields from question table.
- if ($oldversion < 2022020200.07) {
- // Define fields to be dropped from questions.
- $table = new xmldb_table('question');
-
- $field = new xmldb_field('version');
- // Conditionally launch drop field version.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
-
- $field = new xmldb_field('hidden');
- // Conditionally launch drop field hidden.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
-
- // Define index categoryidnumber (not unique) to be dropped form question.
- $index = new xmldb_index('categoryidnumber', XMLDB_INDEX_UNIQUE, ['category', 'idnumber']);
-
- // Conditionally launch drop index categoryidnumber.
- if ($dbman->index_exists($table, $index)) {
- $dbman->drop_index($table, $index);
- }
-
- // Define key category (foreign) to be dropped form questions.
- $key = new xmldb_key('category', XMLDB_KEY_FOREIGN, ['category'], 'question_categories', ['id']);
-
- // Launch drop key category.
- $dbman->drop_key($table, $key);
-
- $field = new xmldb_field('idnumber');
- // Conditionally launch drop field idnumber.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
-
- $field = new xmldb_field('category');
- // Conditionally launch drop field category.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022020200.07);
- }
-
- if ($oldversion < 2022021100.01) {
- $sql = "SELECT preset.*
- FROM {adminpresets} preset
- INNER JOIN {adminpresets_it} it ON preset.id = it.adminpresetid
- WHERE it.name = :name AND it.value = :value AND preset.iscore > 0";
- // Some settings and plugins have been added/removed to the Starter and Full preset. Add them to the core presets if
- // they haven't been included yet.
- $params = ['name' => get_string('starterpreset', 'core_adminpresets'), 'iscore' => 1];
- $starterpreset = $DB->get_record('adminpresets', $params);
- if (!$starterpreset) {
- // Starter admin preset might have been created using the English name.
- $name = get_string_manager()->get_string('starterpreset', 'core_adminpresets', null, 'en');
- $params['name'] = $name;
- $starterpreset = $DB->get_record('adminpresets', $params);
- }
- if (!$starterpreset) {
- // We tried, but we didn't find starter by name. Let's find a core preset that sets 'usecomments' setting to 0.
- $params = ['name' => 'usecomments', 'value' => '0'];
- $starterpreset = $DB->get_record_sql($sql, $params);
- }
-
- $params = ['name' => get_string('fullpreset', 'core_adminpresets')];
- $fullpreset = $DB->get_record_select('adminpresets', 'name = :name and iscore > 0', $params);
- if (!$fullpreset) {
- // Full admin preset might have been created using the English name.
- $name = get_string_manager()->get_string('fullpreset', 'core_adminpresets', null, 'en');
- $params['name'] = $name;
- $fullpreset = $DB->get_record_select('adminpresets', 'name = :name and iscore > 0', $params);
- }
- if (!$fullpreset) {
- // We tried, but we didn't find full by name. Let's find a core preset that sets 'usecomments' setting to 1.
- $params = ['name' => 'usecomments', 'value' => '1'];
- $fullpreset = $DB->get_record_sql($sql, $params);
- }
-
- $settings = [
- // Settings. Hide Guest login button for Starter preset (and back to show for Full).
- [
- 'presetid' => $starterpreset->id,
- 'plugin' => 'none',
- 'name' => 'guestloginbutton',
- 'value' => '0',
- ],
- [
- 'presetid' => $fullpreset->id,
- 'plugin' => 'none',
- 'name' => 'guestloginbutton',
- 'value' => '1',
- ],
- // Settings. Set Activity chooser tabs to "Starred, All, Recommended"(1) for Starter and back it to default(0) for Full.
- [
- 'presetid' => $starterpreset->id,
- 'plugin' => 'none',
- 'name' => 'activitychoosertabmode',
- 'value' => '1',
- ],
- [
- 'presetid' => $fullpreset->id,
- 'plugin' => 'none',
- 'name' => 'activitychoosertabmode',
- 'value' => '0',
- ],
- ];
- foreach ($settings as $notused => $setting) {
- $params = ['adminpresetid' => $setting['presetid'], 'plugin' => $setting['plugin'], 'name' => $setting['name']];
- if (!$DB->record_exists('adminpresets_it', $params)) {
- $record = new \stdClass();
- $record->adminpresetid = $setting['presetid'];
- $record->plugin = $setting['plugin'];
- $record->name = $setting['name'];
- $record->value = $setting['value'];
- $DB->insert_record('adminpresets_it', $record);
- }
- }
-
- $plugins = [
- // Plugins. Blocks. Disable/enable Online users, Recently accessed courses and Starred courses.
- [
- 'presetid' => $starterpreset->id,
- 'plugin' => 'block',
- 'name' => 'online_users',
- 'enabled' => '0',
- ],
- [
- 'presetid' => $fullpreset->id,
- 'plugin' => 'block',
- 'name' => 'online_users',
- 'enabled' => '1',
- ],
- [
- 'presetid' => $starterpreset->id,
- 'plugin' => 'block',
- 'name' => 'recentlyaccessedcourses',
- 'enabled' => '0',
- ],
- [
- 'presetid' => $fullpreset->id,
- 'plugin' => 'block',
- 'name' => 'recentlyaccessedcourses',
- 'enabled' => '1',
- ],
- [
- 'presetid' => $starterpreset->id,
- 'plugin' => 'block',
- 'name' => 'starredcourses',
- 'enabled' => '0',
- ],
- [
- 'presetid' => $fullpreset->id,
- 'plugin' => 'block',
- 'name' => 'starredcourses',
- 'enabled' => '1',
- ],
- // Plugins. Enrolments. Disable/enable Guest access.
- [
- 'presetid' => $starterpreset->id,
- 'plugin' => 'enrol',
- 'name' => 'guest',
- 'enabled' => '0',
- ],
- [
- 'presetid' => $fullpreset->id,
- 'plugin' => 'enrol',
- 'name' => 'guest',
- 'enabled' => '1',
- ],
- ];
- foreach ($plugins as $notused => $plugin) {
- $params = ['adminpresetid' => $plugin['presetid'], 'plugin' => $plugin['plugin'], 'name' => $plugin['name']];
- if (!$DB->record_exists('adminpresets_plug', $params)) {
- $record = new \stdClass();
- $record->adminpresetid = $plugin['presetid'];
- $record->plugin = $plugin['plugin'];
- $record->name = $plugin['name'];
- $record->enabled = $plugin['enabled'];
- $DB->insert_record('adminpresets_plug', $record);
- }
- }
-
- // Settings: Remove customusermenuitems setting from Starter and Full presets.
- $sql = "(adminpresetid = ? OR adminpresetid = ?) AND plugin = 'none' AND name = 'customusermenuitems'";
- $params = [$starterpreset->id, $fullpreset->id];
- $DB->delete_records_select('adminpresets_it', $sql, $params);
-
- // Plugins. Question types. Re-enable Description and Essay for Starter.
- $sql = "(adminpresetid = ? OR adminpresetid = ?) AND plugin = 'qtype' AND (name = 'description' OR name = 'essay')";
- $DB->delete_records_select('adminpresets_plug', $sql, $params);
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022021100.01);
-
- }
-
- if ($oldversion < 2022021100.02) {
- $table = new xmldb_table('task_scheduled');
-
- // Changing precision of field minute on table task_scheduled to (200).
- $field = new xmldb_field('minute', XMLDB_TYPE_CHAR, '200', null, XMLDB_NOTNULL, null, null, 'blocking');
- $dbman->change_field_precision($table, $field);
- // Changing precision of field hour on table task_scheduled to (70).
- $field = new xmldb_field('hour', XMLDB_TYPE_CHAR, '70', null, XMLDB_NOTNULL, null, null, 'minute');
- $dbman->change_field_precision($table, $field);
- // Changing precision of field day on table task_scheduled to (90).
- $field = new xmldb_field('day', XMLDB_TYPE_CHAR, '90', null, XMLDB_NOTNULL, null, null, 'hour');
- $dbman->change_field_precision($table, $field);
- // Changing precision of field month on table task_scheduled to (30).
- $field = new xmldb_field('month', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, 'day');
- $dbman->change_field_precision($table, $field);
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022021100.02);
- }
-
- if ($oldversion < 2022022600.01) {
- // Get all processor and existing preferences.
- $processors = $DB->get_records('message_processors');
- $providers = $DB->get_records('message_providers', null, '', 'id, name, component');
- $existingpreferences = get_config('message');
-
- foreach ($processors as $processor) {
- foreach ($providers as $provider) {
- // Setting default preference name.
- $componentproviderbase = $provider->component . '_' . $provider->name;
- $preferencename = $processor->name.'_provider_'.$componentproviderbase.'_locked';
- // If we do not have this setting yet, set it to 0.
- if (!isset($existingpreferences->{$preferencename})) {
- set_config($preferencename, 0, 'message');
- }
- }
- }
-
- upgrade_main_savepoint(true, 2022022600.01);
- }
-
- if ($oldversion < 2022030100.00) {
- $sql = "SELECT preset.*
- FROM {adminpresets} preset
- INNER JOIN {adminpresets_it} it ON preset.id = it.adminpresetid
- WHERE it.name = :name AND it.value = :value AND preset.iscore > 0";
-
- $name = get_string('starterpreset', 'core_adminpresets');
- $params = ['name' => $name, 'iscore' => 1];
- $starterpreset = $DB->get_record('adminpresets', $params);
- if (!$starterpreset) {
- // Starter admin preset might have been created using the English name. Let's change it to current language.
- $englishname = get_string_manager()->get_string('starterpreset', 'core_adminpresets', null, 'en');
- $params['name'] = $englishname;
- $starterpreset = $DB->get_record('adminpresets', $params);
- }
- if (!$starterpreset) {
- // We tried, but we didn't find starter by name. Let's find a core preset that sets 'usecomments' setting to 0.
- $params = ['name' => 'usecomments', 'value' => '0'];
- $starterpreset = $DB->get_record_sql($sql, $params);
- }
- // The iscore field is already 1 for starterpreset, so we don't need to change it.
- // We only need to update the name and comment in case they are different to current language strings.
- if ($starterpreset && $starterpreset->name != $name) {
- $starterpreset->name = $name;
- $starterpreset->comments = get_string('starterpresetdescription', 'core_adminpresets');
- $DB->update_record('adminpresets', $starterpreset);
- }
-
- // Let's mark Full admin presets with current FULL_PRESETS value and change the name to current language.
- $name = get_string('fullpreset', 'core_adminpresets');
- $params = ['name' => $name];
- $fullpreset = $DB->get_record_select('adminpresets', 'name = :name and iscore > 0', $params);
- if (!$fullpreset) {
- // Full admin preset might have been created using the English name.
- $englishname = get_string_manager()->get_string('fullpreset', 'core_adminpresets', null, 'en');
- $params['name'] = $englishname;
- $fullpreset = $DB->get_record_select('adminpresets', 'name = :name and iscore > 0', $params);
- }
- if (!$fullpreset) {
- // We tried, but we didn't find full by name. Let's find a core preset that sets 'usecomments' setting to 1.
- $params = ['name' => 'usecomments', 'value' => '1'];
- $fullpreset = $DB->get_record_sql($sql, $params);
- }
- if ($fullpreset) {
- // We need to update iscore field value, whether the name is the same or not.
- $fullpreset->name = $name;
- $fullpreset->comments = get_string('fullpresetdescription', 'core_adminpresets');
- $fullpreset->iscore = 2;
- $DB->update_record('adminpresets', $fullpreset);
-
- // We are applying again changes made on 2022011100.01 upgrading step because of MDL-73953 bug.
- $blocknames = ['course_summary', 'feedback', 'rss_client', 'selfcompletion'];
- list($blocksinsql, $blocksinparams) = $DB->get_in_or_equal($blocknames);
-
- // Remove entries from the adminpresets_app_plug table (in case the preset has been applied).
- $appliedpresets = $DB->get_records('adminpresets_app', ['adminpresetid' => $fullpreset->id], '', 'id');
- if ($appliedpresets) {
- list($appsinsql, $appsinparams) = $DB->get_in_or_equal(array_keys($appliedpresets));
- $sql = "adminpresetapplyid $appsinsql AND plugin='block' AND name $blocksinsql";
- $params = array_merge($appsinparams, $blocksinparams);
- $DB->delete_records_select('adminpresets_app_plug', $sql, $params);
- }
-
- // Remove entries for these blocks from the adminpresets_plug table.
- $sql = "adminpresetid = ? AND plugin='block' AND name $blocksinsql";
- $params = array_merge([$fullpreset->id], $blocksinparams);
- $DB->delete_records_select('adminpresets_plug', $sql, $params);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022030100.00);
- }
-
- if ($oldversion < 2022031100.01) {
- $reportsusermenuitem = 'reports,core_reportbuilder|/reportbuilder/index.php';
- upgrade_add_item_to_usermenu($reportsusermenuitem);
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022031100.01);
- }
-
- if ($oldversion < 2022032200.01) {
-
- // Define index to be added to question_references.
- $table = new xmldb_table('question_references');
- $index = new xmldb_index('context-component-area-itemid', XMLDB_INDEX_UNIQUE,
- ['usingcontextid', 'component', 'questionarea', 'itemid']);
-
- // Conditionally launch add field id.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022032200.01);
- }
-
- if ($oldversion < 2022032200.02) {
-
- // Define index to be added to question_references.
- $table = new xmldb_table('question_set_references');
- $index = new xmldb_index('context-component-area-itemid', XMLDB_INDEX_UNIQUE,
- ['usingcontextid', 'component', 'questionarea', 'itemid']);
-
- // Conditionally launch add field id.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022032200.02);
- }
-
- if ($oldversion < 2022041200.01) {
-
- // The original default admin presets "sensible settings" (those that should be treated as sensitive).
- $originalsensiblesettings = 'recaptchapublickey@@none, recaptchaprivatekey@@none, googlemapkey3@@none, ' .
- 'secretphrase@@url, cronremotepassword@@none, smtpuser@@none, smtppass@none, proxypassword@@none, ' .
- 'quizpassword@@quiz, allowedip@@none, blockedip@@none, dbpass@@logstore_database, messageinbound_hostpass@@none, ' .
- 'bind_pw@@auth_cas, pass@@auth_db, bind_pw@@auth_ldap, dbpass@@enrol_database, bind_pw@@enrol_ldap, ' .
- 'server_password@@search_solr, ssl_keypassword@@search_solr, alternateserver_password@@search_solr, ' .
- 'alternatessl_keypassword@@search_solr, test_password@@cachestore_redis, password@@mlbackend_python';
-
- // Check if the current config matches the original default, upgrade to new default if so.
- if (get_config('adminpresets', 'sensiblesettings') === $originalsensiblesettings) {
- $newsensiblesettings = "{$originalsensiblesettings}, badges_badgesalt@@none, calendar_exportsalt@@none";
- set_config('sensiblesettings', $newsensiblesettings, 'adminpresets');
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022041200.01);
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022042900.01) {
- // Social custom fields could had been created linked to category id = 1. Let's check category 1 exists.
- if (!$DB->get_record('user_info_category', ['id' => 1])) {
- // Let's check if we have any custom field linked to category id = 1.
- $fields = $DB->get_records('user_info_field', ['categoryid' => 1]);
- if (!empty($fields)) {
- $categoryid = $DB->get_field_sql('SELECT min(id) from {user_info_category}');
- foreach ($fields as $field) {
- $field->categoryid = $categoryid;
- $DB->update_record('user_info_field', $field);
- }
- }
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022042900.01);
- }
-
- if ($oldversion < 2022051000.00) {
- // Add index to the sid field in the external_tokens table.
- $table = new xmldb_table('external_tokens');
- $index = new xmldb_index('sid', XMLDB_INDEX_NOTUNIQUE, ['sid']);
-
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- upgrade_main_savepoint(true, 2022051000.00);
- }
-
- if ($oldversion < 2022052500.00) {
- // Start an adhoc task to fix the file timestamps of restored files.
- $task = new core\task\fix_file_timestamps_task();
- \core\task\manager::queue_adhoc_task($task);
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022052500.00);
- }
-
- if ($oldversion < 2022052700.01) {
-
- // Define index timestarted_idx (not unique) to be added to task_adhoc.
- $table = new xmldb_table('task_adhoc');
- $index = new xmldb_index('timestarted_idx', XMLDB_INDEX_NOTUNIQUE, ['timestarted']);
-
- // Conditionally launch add index timestarted_idx.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022052700.01);
- }
-
- if ($oldversion < 2022052700.02) {
-
- // Define index filename (not unique) to be added to files.
- $table = new xmldb_table('files');
- $index = new xmldb_index('filename', XMLDB_INDEX_NOTUNIQUE, ['filename']);
-
- // Conditionally launch add index filename.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022052700.02);
- }
-
- if ($oldversion < 2022060300.01) {
-
- // Changing precision of field hidden on table grade_categories to (10).
- $table = new xmldb_table('grade_categories');
- $field = new xmldb_field('hidden', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'timemodified');
-
- // Launch change of precision for field hidden.
- $dbman->change_field_precision($table, $field);
-
- // Changing precision of field hidden on table grade_categories_history to (10).
- $table = new xmldb_table('grade_categories_history');
- $field = new xmldb_field('hidden', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'aggregatesubcats');
-
- // Launch change of precision for field hidden.
- $dbman->change_field_precision($table, $field);
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022060300.01);
- }
-
- if ($oldversion < 2022061000.01) {
- // Iterate over custom user menu items configuration, removing pix icon references.
- $customusermenuitems = str_replace(["\r\n", "\r"], "\n", $CFG->customusermenuitems);
-
- $lines = preg_split('/\n/', $customusermenuitems, -1, PREG_SPLIT_NO_EMPTY);
- $lines = array_map(static function(string $line): string {
- // Previous format was "|[|]" - pix icon is no longer supported.
- $lineparts = explode('|', trim($line), 3);
- // Return first two parts of line.
- return implode('|', array_slice($lineparts, 0, 2));
- }, $lines);
-
- set_config('customusermenuitems', implode("\n", $lines));
-
- upgrade_main_savepoint(true, 2022061000.01);
- }
-
- if ($oldversion < 2022061500.00) {
- // Remove drawer-open-nav user preference for every user.
- $DB->delete_records('user_preferences', ['name' => 'drawer-open-nav']);
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022061500.00);
-
- }
-
- if ($oldversion < 2022072900.00) {
- // Call the helper function that updates the foreign keys and indexes in MDL-49795.
- upgrade_add_foreign_key_and_indexes();
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022072900.00);
- }
-
- if ($oldversion < 2022081200.01) {
-
- // Define field lang to be added to course_modules.
- $table = new xmldb_table('course_modules');
- $field = new xmldb_field('lang', XMLDB_TYPE_CHAR, '30', null, null, null, null, 'downloadcontent');
-
- // Conditionally launch add field lang.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022081200.01);
- }
-
- if ($oldversion < 2022091000.01) {
- $table = new xmldb_table('h5p');
- $indexpathnamehash = new xmldb_index('pathnamehash_idx', XMLDB_INDEX_NOTUNIQUE, ['pathnamehash']);
-
- if (!$dbman->index_exists($table, $indexpathnamehash)) {
- $dbman->add_index($table, $indexpathnamehash);
- }
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022091000.01);
- }
-
- if ($oldversion < 2022092200.01) {
-
- // Remove any orphaned tag instance records (pointing to non-existing context).
- $DB->delete_records_select('tag_instance', 'NOT EXISTS (
- SELECT ctx.id FROM {context} ctx WHERE ctx.id = {tag_instance}.contextid
- )');
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022092200.01);
- }
-
- if ($oldversion < 2022101400.01) {
- $table = new xmldb_table('competency_modulecomp');
- $field = new xmldb_field('overridegrade', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'ruleoutcome');
-
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022101400.01);
- }
-
- if ($oldversion < 2022101400.03) {
- // Define table to store completion viewed.
- $table = new xmldb_table('course_modules_viewed');
-
- // Adding fields to table course_modules_viewed.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('coursemoduleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'id');
- $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'coursemoduleid');
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'userid');
-
- // Adding keys to table course_modules_viewed.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
-
- // Adding indexes to table course_modules_viewed.
- $table->add_index('coursemoduleid', XMLDB_INDEX_NOTUNIQUE, ['coursemoduleid']);
- $table->add_index('userid-coursemoduleid', XMLDB_INDEX_UNIQUE, ['userid', 'coursemoduleid']);
-
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022101400.03);
- }
-
- if ($oldversion < 2022101400.04) {
- // Add legacy data to the new table.
- $transaction = $DB->start_delegated_transaction();
- upgrade_set_timeout(3600);
- $sql = "INSERT INTO {course_modules_viewed}
- (userid, coursemoduleid, timecreated)
- SELECT userid, coursemoduleid, timemodified
- FROM {course_modules_completion}
- WHERE viewed = 1";
- $DB->execute($sql);
- $transaction->allow_commit();
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022101400.04);
- }
-
- if ($oldversion < 2022101400.05) {
- // Define field viewed to be dropped from course_modules_completion.
- $table = new xmldb_table('course_modules_completion');
- $field = new xmldb_field('viewed');
-
- // Conditionally launch drop field viewed.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
-
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022101400.05);
- }
-
- if ($oldversion < 2022102800.01) {
- // For sites with "contact site support" already available (4.0.x), maintain existing functionality.
- if ($oldversion >= 2022041900.00) {
- set_config('supportavailability', CONTACT_SUPPORT_ANYONE);
- } else {
- // Sites which did not previously have the "contact site support" feature default to it requiring authentication.
- set_config('supportavailability', CONTACT_SUPPORT_AUTHENTICATED);
- }
+/**
+ * Main upgrade tasks to be executed on Moodle version bump
+ *
+ * This function is automatically executed after one bump in the Moodle core
+ * version is detected. It's in charge of performing the required tasks
+ * to raise core from the previous version to the next one.
+ *
+ * It's a collection of ordered blocks of code, named "upgrade steps",
+ * each one performing one isolated (from the rest of steps) task. Usually
+ * tasks involve creating new DB objects or performing manipulation of the
+ * information for cleanup/fixup purposes.
+ *
+ * Each upgrade step has a fixed structure, that can be summarised as follows:
+ *
+ * if ($oldversion < XXXXXXXXXX.XX) {
+ * // Explanation of the update step, linking to issue in the Tracker if necessary
+ * upgrade_set_timeout(XX); // Optional for big tasks
+ * // Code to execute goes here, usually the XMLDB Editor will
+ * // help you here. See {@link https://moodledev.io/general/development/tools/xmldb}.
+ * upgrade_main_savepoint(true, XXXXXXXXXX.XX);
+ * }
+ *
+ * All plugins within Moodle (modules, blocks, reports...) support the existence of
+ * their own upgrade.php file, using the "Frankenstyle" component name as
+ * defined at {@link https://moodledev.io/general/development/policies/codingstyle/frankenstyle}, for example:
+ * - {@see xmldb_page_upgrade($oldversion)}. (modules don't require the plugintype ("mod_") to be used.
+ * - {@see xmldb_auth_manual_upgrade($oldversion)}.
+ * - {@see xmldb_workshopform_accumulative_upgrade($oldversion)}.
+ * - ....
+ *
+ * In order to keep the contents of this file reduced, it's allowed to create some helper
+ * functions to be used here in the {@see upgradelib.php} file at the same directory. Note
+ * that such a file must be manually included from upgrade.php, and there are some restrictions
+ * about what can be used within it.
+ *
+ * For more information, take a look to the documentation available:
+ * - Data definition API: {@link https://moodledev.io/docs/apis/core/dml/ddl}
+ * - Upgrade API: {@link https://moodledev.io/docs/guides/upgrade}
+ *
+ * @param int $oldversion
+ * @return bool always true
+ */
+function xmldb_main_upgrade($oldversion) {
+ global $CFG, $DB;
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022102800.01);
- }
+ require_once($CFG->libdir . '/db/upgradelib.php'); // Core Upgrade-related functions.
- if ($oldversion < 2022110600.00) {
- // If webservice_xmlrpc isn't any longer installed, remove its configuration,
- // capabilities and presence in other settings.
- if (!file_exists($CFG->dirroot . '/webservice/xmlrpc/version.php')) {
- // No DB structures to delete in this plugin.
-
- // Remove capabilities.
- capabilities_cleanup('webservice_xmlrpc');
-
- // Remove own configuration.
- unset_all_config_for_plugin('webservice_xmlrpc');
-
- // Remove it from the enabled protocols if it was there.
- $protos = get_config('core', 'webserviceprotocols');
- $protoarr = explode(',', $protos);
- $protoarr = array_filter($protoarr, function($ele) {
- return trim($ele) !== 'xmlrpc';
- });
- $protos = implode(',', $protoarr);
- set_config('webserviceprotocols', $protos);
- }
+ $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
- // Main savepoint reached.
- upgrade_main_savepoint(true, 2022110600.00);
+ // Always keep this upgrade step with version being the minimum
+ // allowed version to upgrade from (v4.1.2 right now).
+ if ($oldversion < 2021112802) {
+ // Just in case somebody hacks upgrade scripts or env, we really can not continue.
+ echo("You need to upgrade to 4.1.2 or higher first!\n");
+ exit(1);
+ // Note this savepoint is 100% unreachable, but needed to pass the upgrade checks.
+ upgrade_main_savepoint(true, 2021112802);
}
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2022120900.01) {
-
// Remove any orphaned role assignment records (pointing to non-existing roles).
$DB->delete_records_select('role_assignments', 'NOT EXISTS (
SELECT r.id FROM {role} r WHERE r.id = {role_assignments}.roleid
@@ -3155,7 +315,6 @@ function xmldb_main_upgrade($oldversion) {
}
if ($oldversion < 2023031400.02) {
-
// Define table xapi_states to be created.
$table = new xmldb_table('xapi_states');
@@ -3219,7 +378,8 @@ function xmldb_main_upgrade($oldversion) {
if (!file_exists($CFG->dirroot . '/mod/assignment/version.php')) {
// Delete all mod_assignment grade_grades orphaned data.
$DB->delete_records_select(
- 'grade_grades', "itemid IN (SELECT id FROM {grade_items} WHERE itemtype = 'mod' AND itemmodule = 'assignment')"
+ 'grade_grades',
+ "itemid IN (SELECT id FROM {grade_items} WHERE itemtype = 'mod' AND itemmodule = 'assignment')"
);
// Delete all mod_assignment grade_grades_history orphaned data.
@@ -3326,15 +486,15 @@ function xmldb_main_upgrade($oldversion) {
$sql = 'UPDATE {external_tokens}
SET name = ' . $DB->sql_concat(
// We only need the prefix, so leave the third param with an empty string.
- "'" . get_string('tokennameprefix', 'webservice', '') . "'",
- "id");
+ "'" . get_string('tokennameprefix', 'webservice', '') . "'",
+ "id"
+ );
$DB->execute($sql);
// Main savepoint reached.
upgrade_main_savepoint(true, 2023062700.01);
}
if ($oldversion < 2023062900.01) {
-
// Define field avatarsynced to be added to communication.
$table = new xmldb_table('communication');
$field = new xmldb_field('avatarsynced', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, 0, 'active');
@@ -3352,7 +512,7 @@ function xmldb_main_upgrade($oldversion) {
// Upgrade yaml mime type for existing yaml and yml files.
$filetypes = [
'%.yaml' => 'application/yaml',
- '%.yml' => 'application/yaml,'
+ '%.yml' => 'application/yaml,',
];
$select = $DB->sql_like('filename', '?', false);
@@ -3472,7 +632,6 @@ function xmldb_main_upgrade($oldversion) {
}
if ($oldversion < 2023082200.04) {
-
// Remove any non-unique filters/conditions.
$duplicates = $DB->get_records_sql("
SELECT MIN(id) AS id, reportid, uniqueidentifier, iscondition
@@ -3568,7 +727,6 @@ function xmldb_main_upgrade($oldversion) {
}
if ($oldversion < 2023090200.01) {
-
// Define table moodlenet_share_progress to be created.
$table = new xmldb_table('moodlenet_share_progress');
diff --git a/lib/editor/atto/db/upgrade.php b/lib/editor/atto/db/upgrade.php
index 5b878d91f3302..fafd77fb6c57a 100644
--- a/lib/editor/atto/db/upgrade.php
+++ b/lib/editor/atto/db/upgrade.php
@@ -22,61 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Run all Atto upgrade steps between the current DB version and the current version on disk.
* @param int $oldversion The old version of atto in the DB.
* @return bool
*/
function xmldb_editor_atto_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021062400) {
- // The old default toolbar config for 311 and below.
- $oldtoolbar = 'collapse = collapse
-style1 = title, bold, italic
-list = unorderedlist, orderedlist, indent
-links = link
-files = emojipicker, image, media, recordrtc, managefiles, h5p
-style2 = underline, strike, subscript, superscript
-align = align
-insert = equation, charmap, table, clear
-undo = undo
-accessibility = accessibilitychecker, accessibilityhelper
-other = html';
-
- // Check if the current toolbar config matches the old toolbar config.
- $sametoolbar = str_replace(["\r\n", "\r"], "\n", get_config('editor_atto', 'toolbar')) == $oldtoolbar;
- // Check if the current showgroups config matches the old showgroups config.
- $sameshowgroups = get_config('atto_collapse', 'showgroups') == 5;
-
- if ($sametoolbar && $sameshowgroups) {
- // If the site is still using the old defaults, upgrade to the new default.
- $newtoolbar = 'collapse = collapse
-style1 = title, bold, italic
-list = unorderedlist, orderedlist, indent
-links = link
-files = emojipicker, image, media, recordrtc, managefiles, h5p
-accessibility = accessibilitychecker, accessibilityhelper
-style2 = underline, strike, subscript, superscript
-align = align
-insert = equation, charmap, table, clear
-undo = undo
-other = html';
- set_config('toolbar', $newtoolbar, 'editor_atto');
- set_config('showgroups', 6, 'atto_collapse');
- }
-
- upgrade_plugin_savepoint(true, 2021062400, 'editor', 'atto');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/lib/editor/atto/plugins/equation/db/upgrade.php b/lib/editor/atto/plugins/equation/db/upgrade.php
index 06ef4c85e82a8..adf83d5478373 100644
--- a/lib/editor/atto/plugins/equation/db/upgrade.php
+++ b/lib/editor/atto/plugins/equation/db/upgrade.php
@@ -22,32 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Run all Atto equation upgrade steps between the current DB version and the current version on disk.
* @param int $oldversion The old version of atto equation in the DB.
* @return bool
*/
function xmldb_atto_equation_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022110700) {
- $oldmatrix = '\left| \begin{matrix} a_1 & a_2 \\ a_3 & a_4 \end{matrix} \right|';
- $fixedmatrix = '\left| \begin{matrix} a_1 & a_2 \\\\ a_3 & a_4 \end{matrix} \right|';
- $config = get_config('atto_equation', 'librarygroup4');
- $newdefault = str_replace($oldmatrix, $fixedmatrix, $config);
- set_config('librarygroup4', $newdefault, 'atto_equation');
- // Atto equation savepoint reached.
- upgrade_plugin_savepoint(true, 2022110700, 'atto', 'equation');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/lib/editor/atto/plugins/recordrtc/db/upgrade.php b/lib/editor/atto/plugins/recordrtc/db/upgrade.php
index 98962c1713fd7..f5c08aba072dd 100644
--- a/lib/editor/atto/plugins/recordrtc/db/upgrade.php
+++ b/lib/editor/atto/plugins/recordrtc/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the recordrtc atto text editor.
*
@@ -31,23 +29,6 @@
* @return bool
*/
function xmldb_atto_recordrtc_upgrade($oldversion) {
- global $CFG;
-
- // Change settings from timelimit to audiotimelimit and videotimelimit.
- require_once($CFG->dirroot . '/lib/editor/atto/plugins/recordrtc/lib.php');
- if ($oldversion < 2021073000) {
- $timelimit = get_config('atto_recordrtc', 'timelimit');
- if ($timelimit != DEFAULT_TIME_LIMIT) {
- set_config('audiotimelimit', $timelimit, 'atto_recordrtc');
- set_config('videotimelimit', $timelimit, 'atto_recordrtc');
- }
- // Recordrtc savepoint reached.
- upgrade_plugin_savepoint(true, 2021073000, 'atto', 'recordrtc');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/media/player/videojs/db/upgrade.php b/media/player/videojs/db/upgrade.php
index 515f5eda1ff8f..4964964f9ebd4 100644
--- a/media/player/videojs/db/upgrade.php
+++ b/media/player/videojs/db/upgrade.php
@@ -42,8 +42,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
-
/**
* Main upgrade tasks to be executed on plugin version bump.
*
@@ -51,20 +49,6 @@
* @return bool always true
*/
function xmldb_media_videojs_upgrade($oldversion) {
- global $CFG;
-
- if ($oldversion < 2021052503) {
- // Remove useflash and rtmp settings.
- unset_config('useflash', 'media_videojs');
- unset_config('rtmp', 'media_videojs');
-
- // Main savepoint reached.
- upgrade_plugin_savepoint(true, 2021052503, 'media', 'videojs');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/message/output/email/db/upgrade.php b/message/output/email/db/upgrade.php
index 8160acc94cfa4..96a2bd3f9fd01 100644
--- a/message/output/email/db/upgrade.php
+++ b/message/output/email/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the email message processor
*
* @param int $oldversion The version that we are upgrading from
*/
function xmldb_message_email_upgrade($oldversion) {
- global $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/message/output/popup/db/upgrade.php b/message/output/popup/db/upgrade.php
index accb4fac63d27..e41d3f76bc28a 100644
--- a/message/output/popup/db/upgrade.php
+++ b/message/output/popup/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the popup message processor
*
* @param int $oldversion The version that we are upgrading from
*/
function xmldb_message_popup_upgrade($oldversion) {
- global $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/assign/db/upgrade.php b/mod/assign/db/upgrade.php
index 0fb85626dd5dd..62a06d12441b6 100644
--- a/mod/assign/db/upgrade.php
+++ b/mod/assign/db/upgrade.php
@@ -22,114 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* upgrade this assignment instance - this function could be skipped but it will be needed later
* @param int $oldversion The old version of the assign module
* @return bool
*/
function xmldb_assign_upgrade($oldversion) {
- global $CFG, $DB;
-
- $dbman = $DB->get_manager();
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021110901) {
- // Define field activity to be added to assign.
- $table = new xmldb_table('assign');
- $field = new xmldb_field('activity', XMLDB_TYPE_TEXT, null, null, null, null, null, 'alwaysshowdescription');
-
- // Conditionally launch add field activity.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- $field = new xmldb_field('activityformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'activity');
-
- // Conditionally launch add field activityformat.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- $field = new xmldb_field('timelimit', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'cutoffdate');
-
- // Conditionally launch add field timelimit.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- $field = new xmldb_field('submissionattachments', XMLDB_TYPE_INTEGER, '2',
- null, XMLDB_NOTNULL, null, '0', 'activityformat');
-
- // Conditionally launch add field submissionattachments.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- $table = new xmldb_table('assign_submission');
- $field = new xmldb_field('timestarted', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'timemodified');
-
- // Conditionally launch add field timestarted.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field timelimit to be added to assign_overrides.
- $table = new xmldb_table('assign_overrides');
- $field = new xmldb_field('timelimit', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'cutoffdate');
-
- // Conditionally launch add field timelimit.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Assign savepoint reached.
- upgrade_mod_savepoint(true, 2021110901, 'assign');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022071300) {
- // The most recent assign submission should always have latest = 1, we want to find all records where this is not the case.
- // Find the records with the maximum timecreated for each assign and user combination where latest is also 0.
- $sqluser = "SELECT s.id
- FROM {assign_submission} s
- WHERE s.timecreated = (
- SELECT MAX(timecreated) timecreated
- FROM {assign_submission} sm
- WHERE s.assignment = sm.assignment
- AND s.userid = sm.userid
- AND sm.groupid = 0)
- AND s.groupid = 0
- AND s.latest = 0";
- $idstofixuser = $DB->get_records_sql($sqluser, null);
-
- $sqlgroup = "SELECT s.id
- FROM {assign_submission} s
- WHERE s.timecreated = (
- SELECT MAX(timecreated) timecreated
- FROM {assign_submission} sm
- WHERE s.assignment = sm.assignment
- AND s.groupid = sm.groupid
- AND sm.groupid <> 0)
- AND s.groupid <> 0
- AND s.latest = 0";
- $idstofixgroup = $DB->get_records_sql($sqlgroup, null);
-
- $idstofix = array_merge(array_keys($idstofixuser), array_keys($idstofixgroup));
-
- if (count($idstofix)) {
- [$insql, $inparams] = $DB->get_in_or_equal($idstofix);
- $DB->set_field_select('assign_submission', 'latest', 1, "id $insql", $inparams);
- }
-
- // Assignment savepoint reached.
- upgrade_mod_savepoint(true, 2022071300, 'assign');
- }
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/assign/feedback/comments/db/upgrade.php b/mod/assign/feedback/comments/db/upgrade.php
index c2cb24876eaa3..b77eccb3de4cb 100644
--- a/mod/assign/feedback/comments/db/upgrade.php
+++ b/mod/assign/feedback/comments/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Stub for upgrade code
* @param int $oldversion
* @return bool
*/
function xmldb_assignfeedback_comments_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/assign/feedback/editpdf/db/upgrade.php b/mod/assign/feedback/editpdf/db/upgrade.php
index 42bc0249c4e7e..4ab535ffb9c03 100644
--- a/mod/assign/feedback/editpdf/db/upgrade.php
+++ b/mod/assign/feedback/editpdf/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* EditPDF upgrade code
* @param int $oldversion
@@ -34,65 +32,6 @@ function xmldb_assignfeedback_editpdf_upgrade($oldversion) {
$dbman = $DB->get_manager();
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021060400) {
- // Remove submissions from the processing queue that have been processed.
- $sql = 'DELETE
- FROM {assignfeedback_editpdf_queue}
- WHERE EXISTS (SELECT 1
- FROM {assign_submission} s,
- {assign_grades} g
- WHERE s.id = submissionid
- AND s.assignment = g.assignment
- AND s.userid = g.userid
- AND s.attemptnumber = g.attemptnumber)';
-
- $DB->execute($sql);
-
- // Editpdf savepoint reached.
- upgrade_plugin_savepoint(true, 2021060400, 'assignfeedback', 'editpdf');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022061000) {
- $table = new xmldb_table('assignfeedback_editpdf_queue');
- if ($dbman->table_exists($table)) {
- // Convert not yet converted submissions into adhoc tasks.
- $rs = $DB->get_recordset('assignfeedback_editpdf_queue');
- foreach ($rs as $record) {
- $data = [
- 'submissionid' => $record->submissionid,
- 'submissionattempt' => $record->submissionattempt,
- ];
- $task = new assignfeedback_editpdf\task\convert_submission;
- $task->set_custom_data($data);
- \core\task\manager::queue_adhoc_task($task, true);
- }
- $rs->close();
-
- // Drop the table.
- $dbman->drop_table($table);
- }
-
- // Editpdf savepoint reached.
- upgrade_plugin_savepoint(true, 2022061000, 'assignfeedback', 'editpdf');
- }
-
- if ($oldversion < 2022082200) {
- // Conversion records need to be removed in order for conversions to restart.
- $DB->delete_records('file_conversion');
-
- // Schedule an adhoc task to fix existing stale conversions.
- $task = new \assignfeedback_editpdf\task\bump_submission_for_stale_conversions();
- \core\task\manager::queue_adhoc_task($task);
-
- upgrade_plugin_savepoint(true, 2022082200, 'assignfeedback', 'editpdf');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/assign/feedback/file/db/upgrade.php b/mod/assign/feedback/file/db/upgrade.php
index db23ac0ac2e60..f9a4e5f2a84c2 100644
--- a/mod/assign/feedback/file/db/upgrade.php
+++ b/mod/assign/feedback/file/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Stub for upgrade code
* @param int $oldversion
* @return bool
*/
function xmldb_assignfeedback_file_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/assign/submission/comments/db/upgrade.php b/mod/assign/submission/comments/db/upgrade.php
index e618c6294212d..9fc6a20c7adc4 100644
--- a/mod/assign/submission/comments/db/upgrade.php
+++ b/mod/assign/submission/comments/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Stub for upgrade code
* @param int $oldversion
* @return bool
*/
function xmldb_assignsubmission_comments_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/assign/submission/file/db/upgrade.php b/mod/assign/submission/file/db/upgrade.php
index 43b296bbb71dd..fcc9be2af6895 100644
--- a/mod/assign/submission/file/db/upgrade.php
+++ b/mod/assign/submission/file/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Stub for upgrade code
* @param int $oldversion
* @return bool
*/
function xmldb_assignsubmission_file_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/assign/submission/onlinetext/db/upgrade.php b/mod/assign/submission/onlinetext/db/upgrade.php
index 989a613b8294d..ae0df7a7e2d2b 100644
--- a/mod/assign/submission/onlinetext/db/upgrade.php
+++ b/mod/assign/submission/onlinetext/db/upgrade.php
@@ -22,22 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Stub for upgrade code
* @param int $oldversion
* @return bool
*/
function xmldb_assignsubmission_onlinetext_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/bigbluebuttonbn/db/upgrade.php b/mod/bigbluebuttonbn/db/upgrade.php
index a4164c5f95be9..0223fa905e82e 100644
--- a/mod/bigbluebuttonbn/db/upgrade.php
+++ b/mod/bigbluebuttonbn/db/upgrade.php
@@ -37,456 +37,10 @@
function xmldb_bigbluebuttonbn_upgrade($oldversion = 0) {
global $DB;
$dbman = $DB->get_manager();
- if ($oldversion < 2015080605) {
- // Drop field description.
- $table5 = new xmldb_table('bigbluebuttonbn');
- $field4 = new xmldb_field('description');
- if ($dbman->field_exists($table5, $field4)) {
- $dbman->drop_field($table5, $field4, true, true);
- }
- // Change welcome, allow null.
- $fielddefinition = ['type' => XMLDB_TYPE_TEXT, 'precision' => null, 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => null, 'previous' => 'type'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'welcome',
- $fielddefinition);
- // Change userid definition in bigbluebuttonbn_log.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '10', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => null,
- 'previous' => 'bigbluebuttonbnid'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn_log', 'userid',
- $fielddefinition);
- // No settings to migrate.
- // Update db version tag.
- upgrade_mod_savepoint(true, 2015080605, 'bigbluebuttonbn');
- }
- if ($oldversion < 2016011305) {
- // Define field type to be droped from bigbluebuttonbn.
- $table4 = new xmldb_table('bigbluebuttonbn');
- $field3 = new xmldb_field('type');
- if ($dbman->field_exists($table4, $field3)) {
- $dbman->drop_field($table4, $field3, true, true);
- }
- // Rename table bigbluebuttonbn_log to bigbluebuttonbn_logs.
- $table = new xmldb_table('bigbluebuttonbn_log');
- if ($dbman->table_exists($table)) {
- $dbman->rename_table($table, 'bigbluebuttonbn_logs', true, true);
- }
- // Rename field event to log in table bigbluebuttonbn_logs.
- $table1 = new xmldb_table('bigbluebuttonbn_logs');
- $field = new xmldb_field('event');
- if ($dbman->field_exists($table1, $field)) {
- $dbman->rename_field($table1, $field, 'log', true, true);
- }
- // No settings to migrate.
- // Update db version tag.
- upgrade_mod_savepoint(true, 2016011305, 'bigbluebuttonbn');
- }
- if ($oldversion < 2017101000) {
- // Drop field newwindow.
- $table3 = new xmldb_table('bigbluebuttonbn');
- $field2 = new xmldb_field('newwindow');
- if ($dbman->field_exists($table3, $field2)) {
- $dbman->drop_field($table3, $field2, true, true);
- }
- // Add field type.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '2', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => 'id'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'type',
- $fielddefinition);
- // Add field recordings_html.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'recordings_html',
- $fielddefinition);
- // Add field recordings_deleted.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 1, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'recordings_deleted',
- $fielddefinition);
- // Add field recordings_imported.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'recordings_imported',
- $fielddefinition);
- // Drop field newwindow.
- $table2 = new xmldb_table('bigbluebuttonbn');
- $field1 = new xmldb_field('tagging');
- if ($dbman->field_exists($table2, $field1)) {
- $dbman->drop_field($table2, $field1, true, true);
- }
- // Migrate settings.
- unset_config('bigbluebuttonbn_recordingtagging_default', '');
- unset_config('bigbluebuttonbn_recordingtagging_editable', '');
- $cfgvalue = get_config('', 'bigbluebuttonbn_importrecordings_from_deleted_activities_enabled');
- set_config('bigbluebuttonbn_importrecordings_from_deleted_enabled', $cfgvalue, '');
- unset_config('bigbluebuttonbn_importrecordings_from_deleted_activities_enabled', '');
- $cfgvalue = get_config('', 'bigbluebuttonbn_moderator_default');
- set_config('bigbluebuttonbn_participant_moderator_default', $cfgvalue, '');
- unset_config('bigbluebuttonbn_moderator_default', '');
- // Update db version tag.
- upgrade_mod_savepoint(true, 2017101000, 'bigbluebuttonbn');
- }
- if ($oldversion < 2017101009) {
- // Add field recordings_preview.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'recordings_preview',
- $fielddefinition);
- // Update db version tag.
- upgrade_mod_savepoint(true, 2017101009, 'bigbluebuttonbn');
- }
- if ($oldversion < 2017101010) {
- // Fix for CONTRIB-7221.
- if ($oldversion == 2017101003) {
- // A bug intorduced in 2017101003 causes new instances to be created without BBB passwords.
- // A workaround was put in place in version 2017101004 that was relabeled to 2017101005.
- // However, as the code was relocated to upgrade.php in version 2017101010, a new issue came up.
- // There is now a timeout error when the plugin is upgraded in large Moodle sites.
- // The script should only be considered when migrating from this version.
- $sql = "SELECT * FROM {bigbluebuttonbn} ";
- $sql .= "WHERE moderatorpass = ? OR viewerpass = ?";
- $instances = $DB->get_records_sql($sql, ['', '']);
- foreach ($instances as $instance) {
- $instance->moderatorpass = plugin::random_password(12);
- $instance->viewerpass = plugin::random_password(12, $instance->moderatorpass);
- // Store passwords in the database.
- $DB->update_record('bigbluebuttonbn', $instance);
- }
- }
- // Update db version tag.
- upgrade_mod_savepoint(true, 2017101010, 'bigbluebuttonbn');
- }
- if ($oldversion < 2017101012) {
- // Update field type (Fix for CONTRIB-7302).
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '2', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => 'id'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'type',
- $fielddefinition);
- // Update field meetingid (Fix for CONTRIB-7302).
- $fielddefinition = ['type' => XMLDB_TYPE_CHAR, 'precision' => '255', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => null, 'previous' => 'introformat'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'meetingid',
- $fielddefinition);
- // Update field recordings_imported (Fix for CONTRIB-7302).
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'recordings_imported',
- $fielddefinition);
- // Add field recordings_preview.(Fix for CONTRIB-7302).
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'recordings_preview',
- $fielddefinition);
- // Update db version tag.
- upgrade_mod_savepoint(true, 2017101012, 'bigbluebuttonbn');
- }
- if ($oldversion < 2017101015) {
- // Add field for client technology choice.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'clienttype',
- $fielddefinition);
- // Update db version tag.
- upgrade_mod_savepoint(true, 2017101015, 'bigbluebuttonbn');
- }
- if ($oldversion < 2019042000) {
- // Add field for Mute on start feature.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'muteonstart',
- $fielddefinition);
- // Add field for record all from start.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'recordallfromstart',
- $fielddefinition);
- // Add field for record hide button.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'recordhidebutton',
- $fielddefinition);
- // Update db version tag.
- upgrade_mod_savepoint(true, 2019042000, 'bigbluebuttonbn');
- }
- if ($oldversion < 2019101001) {
- // Add field for Completion with attendance.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '9', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'completionattendance',
- $fielddefinition);
- // Add field for Completion with engagement through chats.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '9', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'completionengagementchats',
- $fielddefinition);
- // Add field for Completion with engagement through talks.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '9', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'completionengagementtalks',
- $fielddefinition);
- // Add field for Completion with engagement through raisehand.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '9', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'completionengagementraisehand',
- $fielddefinition);
- // Add field for Completion with engagement through pollvotes.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '9', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'completionengagementpollvotes',
- $fielddefinition);
- // Add field for Completion with engagement through emojis.
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '9', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => null];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'completionengagementemojis',
- $fielddefinition);
- // Add index to bigbluebuttonbn_logs (Fix for CONTRIB-8157).
- xmldb_bigbluebuttonbn_index_table($dbman, 'bigbluebuttonbn_logs', 'courseid',
- ['courseid']);
- xmldb_bigbluebuttonbn_index_table($dbman, 'bigbluebuttonbn_logs', 'log',
- ['log']);
- xmldb_bigbluebuttonbn_index_table($dbman, 'bigbluebuttonbn_logs', 'logrow',
- ['courseid', 'bigbluebuttonbnid', 'userid', 'log']);
- // Update db version tag.
- upgrade_mod_savepoint(true, 2019101001, 'bigbluebuttonbn');
- }
-
- if ($oldversion < 2019101002) {
-
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => 'muteonstart'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'disablecam',
- $fielddefinition);
-
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => 'disablecam'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'disablemic',
- $fielddefinition);
-
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => 'disablemic'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'disableprivatechat',
- $fielddefinition);
-
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => 'disableprivatechat'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'disablepublicchat',
- $fielddefinition);
-
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => 'disablepublicchat'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'disablenote',
- $fielddefinition);
-
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => 'disablenote'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'hideuserlist',
- $fielddefinition);
-
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => 'hideuserlist'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'lockedlayout',
- $fielddefinition);
-
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => 'lockedlayout'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'lockonjoin',
- $fielddefinition);
- $fielddefinition = ['type' => XMLDB_TYPE_INTEGER, 'precision' => '1', 'unsigned' => null,
- 'notnull' => XMLDB_NOTNULL, 'sequence' => null, 'default' => 0, 'previous' => 'lockonjoin'];
- xmldb_bigbluebuttonbn_add_change_field($dbman, 'bigbluebuttonbn', 'lockonjoinconfigurable',
- $fielddefinition);
-
- // Bigbluebuttonbn savepoint reached.
- upgrade_mod_savepoint(true, 2019101002, 'bigbluebuttonbn');
- }
-
- if ($oldversion < 2019101004) {
- // Add index to bigbluebuttonbn_logs (Leftover for CONTRIB-8157).
- xmldb_bigbluebuttonbn_index_table($dbman, 'bigbluebuttonbn_logs', 'userlog',
- ['userid', 'log']);
- // Bigbluebuttonbn savepoint reached.
- upgrade_mod_savepoint(true, 2019101004, 'bigbluebuttonbn');
- }
-
- if ($oldversion < 2021072905) {
- // Add table bigbluebuttonbn_recordings (CONTRIB-7994).
- // Define table bigbluebuttonbn_recordings to be created.
- $table = new xmldb_table('bigbluebuttonbn_recordings');
-
- // Adding fields to table bigbluebuttonbn_recordings.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('bigbluebuttonbnid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('groupid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
- $table->add_field('recordingid', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null);
- $table->add_field('headless', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('imported', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('state', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('recording', XMLDB_TYPE_TEXT, null, null, null, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table bigbluebuttonbn_recordings.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('fk_bigbluebuttonbnid', XMLDB_KEY_FOREIGN, ['bigbluebuttonbnid'], 'bigbluebuttonbn', ['id']);
- $table->add_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
-
- // Adding indexes to table bigbluebuttonbn_recordings.
- $table->add_index('courseid', XMLDB_INDEX_NOTUNIQUE, ['courseid']);
- $table->add_index('recordingid', XMLDB_INDEX_NOTUNIQUE, ['recordingid']);
-
- // Conditionally launch create table for bigbluebuttonbn_recordings.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
- // Bigbluebuttonbn savepoint reached.
- upgrade_mod_savepoint(true, 2021072905, 'bigbluebuttonbn');
- }
- if ($oldversion < 2021072906) {
-
- // Rename field recording on table bigbluebuttonbn_recordings to remotedata, add new remotedatatstamp and status.
- $table = new xmldb_table('bigbluebuttonbn_recordings');
-
- $field = new xmldb_field('recording', XMLDB_TYPE_TEXT, null, null, null, null, null, 'state');
- // Launch rename field recording to remotedata.
- if ($dbman->field_exists($table, $field)) {
- $dbman->rename_field($table, $field, 'remotedata');
- }
- $field = new xmldb_field('remotedatatstamp', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
- // Conditionally launch add field remotedatatstamp.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // State is already used on remote bigbluebutton entity and has not the same semantic.
- $field = new xmldb_field('state', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'imported');
- // Launch rename field state to status.
- if ($dbman->field_exists($table, $field)) {
- $dbman->rename_field($table, $field, 'status');
- }
- // Bigbluebuttonbn savepoint reached.
- upgrade_mod_savepoint(true, 2021072906, 'bigbluebuttonbn');
- }
-
- if ($oldversion < 2021072907) {
- // Define field id to be dropped from bigbluebuttonbn_recordings.
- $table = new xmldb_table('bigbluebuttonbn_recordings');
- $remotedatatstamp = new xmldb_field('remotedatatstamp');
- $remotedata = new xmldb_field('remotedata', XMLDB_TYPE_TEXT, null, null, null, null, null, 'status');
- // Conditionally launch drop field remotedatatstamp.
- if ($dbman->field_exists($table, $remotedatatstamp)) {
- $dbman->drop_field($table, $remotedatatstamp);
- }
- // Launch rename field importeddata.
- if ($dbman->field_exists($table, $remotedata)) {
- $dbman->rename_field($table, $remotedata, 'importeddata');
- }
- // Bigbluebuttonbn savepoint reached.
- upgrade_mod_savepoint(true, 2021072907, 'bigbluebuttonbn');
- }
-
- if ($oldversion < 2021083100) {
- // Update the legacy notifications to use the legacy class which will be removed as per the deprecation policy.
- $DB->set_field('task_adhoc', 'classname', '\mod_bigbluebuttonbn\task\send_legacy_notification', [
- 'component' => 'mod_bigbluebuttonbn',
- 'classname' => '\mod_bigbluebuttonbn\task\send_notification',
- ]);
-
- // Bigbluebuttonbn savepoint reached.
- upgrade_mod_savepoint(true, 2021083100, 'bigbluebuttonbn');
- }
-
- if ($oldversion < 2021091408) {
- // Change BigBliueButton Server credentials to new defaults if test-install is being used.
- if (config::get('server_url') == 'http://test-install.blindsidenetworks.com/bigbluebutton/') {
- set_config('bigbluebuttonbn_server_url', config::DEFAULT_SERVER_URL);
- set_config('bigbluebuttonbn_shared_secret', config::DEFAULT_SHARED_SECRET);
- }
- // Bigbluebuttonbn savepoint reached.
- upgrade_mod_savepoint(true, 2021091408, 'bigbluebuttonbn');
- }
-
- if ($oldversion < 2022021601) {
- // Create adhoc task for upgrading of existing bigbluebuttonbn_logs related to recordings.
- upgrade_recordings_task::schedule_upgrade_per_meeting();
- upgrade_recordings_task::schedule_upgrade_per_meeting(true);
- // Bigbluebuttonbn savepoint reached.
- upgrade_mod_savepoint(true, 2022021601, 'bigbluebuttonbn');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022050600) {
-
- set_config('bigbluebuttonbn_default_dpa_accepted', false);
-
- // If the default server configuration is used.
- if (config::get('server_url') === config::DEFAULT_SERVER_URL) {
- // Disable the BigBlueButton activity module.
- $DB->set_field('modules', 'visible', 0, ['name' => 'bigbluebuttonbn']);
-
- // Use an adhoc task to send a notification to inform the admin that the BigBlueButton activity module
- // has been disabled and they are required to confirm their acceptance of the data processing agreement
- // prior to re-enabling it.
- $notificationtask = new mod_bigbluebuttonbn\task\send_bigbluebutton_module_disabled_notification();
- core\task\manager::queue_adhoc_task($notificationtask);
- }
-
- // Bigbluebuttonbn savepoint reached.
- upgrade_mod_savepoint(true, 2022050600, 'bigbluebuttonbn');
- }
- if ($oldversion < 2022080400) {
-
- // Define field lockonjoin to be dropped from bigbluebuttonbn.
- $table = new xmldb_table('bigbluebuttonbn');
- $field = new xmldb_field('lockonjoin');
- // Conditionally launch drop field lockonjoin.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
- $field = new xmldb_field('lockonjoinconfigurable');
- // Conditionally launch drop field lockonjoinconfigurable.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
- // Bigbluebuttonbn savepoint reached.
- upgrade_mod_savepoint(true, 2022080400, 'bigbluebuttonbn');
- }
- if ($oldversion < 2022101900) {
- $table = new xmldb_table('bigbluebuttonbn');
-
- $field = new xmldb_field('guestallowed', XMLDB_TYPE_INTEGER, '2', null, null, null, '0', 'completionengagementemojis');
- // Conditionally launch add field guestallowed.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- $field = new xmldb_field('mustapproveuser', XMLDB_TYPE_INTEGER, '2', null, null, null, '1', 'guestallowed');
- // Conditionally launch add field mustapproveuser.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- $field = new xmldb_field('guestlinkuid', XMLDB_TYPE_CHAR, '1024', null, null, null, null, 'mustapproveuser');
- // Conditionally launch add field guestlinkuid.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- $field = new xmldb_field('guestpassword', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'guestlinkuid');
- // Conditionally launch add field guestpassword.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
- upgrade_mod_savepoint(true, 2022101900, 'bigbluebuttonbn');
- }
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2023011800) {
-
// Define index course_bbbid_ix (not unique) to be added to bigbluebuttonbn_logs.
$table = new xmldb_table('bigbluebuttonbn_logs');
$index = new xmldb_index('course_bbbid_ix', XMLDB_INDEX_NOTUNIQUE, ['courseid', 'bigbluebuttonbnid']);
@@ -500,7 +54,6 @@ function xmldb_bigbluebuttonbn_upgrade($oldversion = 0) {
upgrade_mod_savepoint(true, 2023011800, 'bigbluebuttonbn');
}
if ($oldversion < 2023021300) {
-
// Define field lockedlayout to be dropped from bigbluebuttonbn.
$table = new xmldb_table('bigbluebuttonbn');
$field = new xmldb_field('lockedlayout');
@@ -532,13 +85,23 @@ function xmldb_bigbluebuttonbn_upgrade($oldversion = 0) {
* @param array $fielddefinition
* @deprecated please do not use this anymore (historical migrations)
*/
-function xmldb_bigbluebuttonbn_add_change_field(database_manager $dbman, string $tablename, string $fieldname,
- array $fielddefinition) {
+function xmldb_bigbluebuttonbn_add_change_field(
+ database_manager $dbman,
+ string $tablename,
+ string $fieldname,
+ array $fielddefinition
+) {
$table = new xmldb_table($tablename);
$field = new xmldb_field($fieldname);
- $field->set_attributes($fielddefinition['type'], $fielddefinition['precision'], $fielddefinition['unsigned'],
- $fielddefinition['notnull'], $fielddefinition['sequence'], $fielddefinition['default'],
- $fielddefinition['previous']);
+ $field->set_attributes(
+ $fielddefinition['type'],
+ $fielddefinition['precision'],
+ $fielddefinition['unsigned'],
+ $fielddefinition['notnull'],
+ $fielddefinition['sequence'],
+ $fielddefinition['default'],
+ $fielddefinition['previous']
+ );
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field, true, true);
return;
@@ -564,8 +127,13 @@ function xmldb_bigbluebuttonbn_add_change_field(database_manager $dbman, string
* @param string|false|null $indextype
* @deprecated please do not use this anymore (historical migrations)
*/
-function xmldb_bigbluebuttonbn_index_table(database_manager $dbman, string $tablename, string $indexname, array $indexfields,
- $indextype = XMLDB_INDEX_NOTUNIQUE) {
+function xmldb_bigbluebuttonbn_index_table(
+ database_manager $dbman,
+ string $tablename,
+ string $indexname,
+ array $indexfields,
+ $indextype = XMLDB_INDEX_NOTUNIQUE
+) {
$table = new xmldb_table($tablename);
if (!$dbman->table_exists($table)) {
return;
diff --git a/mod/book/db/upgrade.php b/mod/book/db/upgrade.php
index e026c754afdfb..c2b260eb1175f 100644
--- a/mod/book/db/upgrade.php
+++ b/mod/book/db/upgrade.php
@@ -21,8 +21,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
-
/**
* Book module upgrade task
*
@@ -30,35 +28,6 @@
* @return bool always true
*/
function xmldb_book_upgrade($oldversion) {
- global $CFG, $DB;
-
- $dbman = $DB->get_manager();
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
- $table = new xmldb_table('book_chapters');
- $index = new xmldb_index('bookid', XMLDB_INDEX_NOTUNIQUE, ['bookid']);
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
- upgrade_mod_savepoint(true, 2021052501, 'book');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
- if ($oldversion < 2022053000) {
- // Define key course (foreign) to be added to book.
- $table = new xmldb_table('book');
- $key = new xmldb_key('course', XMLDB_KEY_FOREIGN, ['course'], 'course', ['id']);
- // Launch add key course.
- $dbman->add_key($table, $key);
-
- // Book savepoint reached.
- upgrade_mod_savepoint(true, 2022053000, 'book');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/chat/db/upgrade.php b/mod/chat/db/upgrade.php
index 4e4241864ef8f..e8aaf6d6e8dd4 100644
--- a/mod/chat/db/upgrade.php
+++ b/mod/chat/db/upgrade.php
@@ -22,31 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_chat_upgrade($oldversion) {
- global $CFG, $DB;
-
- require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions.
-
- $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
- if ($oldversion < 2022053000) {
- // Define key course (foreign) to be added to chat_users.
- $table = new xmldb_table('chat_users');
- $key = new xmldb_key('course', XMLDB_KEY_FOREIGN, ['course'], 'course', ['id']);
- // Launch add key course.
- $dbman->add_key($table, $key);
-
- // Chat savepoint reached.
- upgrade_mod_savepoint(true, 2022053000, 'chat');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/choice/db/upgrade.php b/mod/choice/db/upgrade.php
index 88ee85bc00f7d..6de8108176967 100644
--- a/mod/choice/db/upgrade.php
+++ b/mod/choice/db/upgrade.php
@@ -1,49 +1,45 @@
.
+
+/**
+ * This file keeps track of upgrades to the choice module
+ *
+ * Sometimes, changes between versions involve
+ * alterations to database structures and other
+ * major things that may break installations.
+ *
+ * The upgrade function in this file will attempt
+ * to perform all the necessary actions to upgrade
+ * your older installation to the current version.
+ *
+ * If there's something it cannot do itself, it
+ * will tell you what you need to do.
+ *
+ * The commands in here will all be database-neutral,
+ * using the methods of database_manager class
+ *
+ * Please do not forget to use upgrade_set_timeout()
+ * before any action that may take longer time to finish.
+ *
+ * @package mod_choice
+ * @copyright 2006 Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
function xmldb_choice_upgrade($oldversion) {
- global $CFG, $DB;
-
- $dbman = $DB->get_manager();
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2020061600) {
- // Define field showavailable to be added to choice.
- $table = new xmldb_table('choice');
- $field = new xmldb_field('showavailable', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'completionsubmit');
-
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Choice savepoint reached.
- upgrade_mod_savepoint(true, 2020061600, 'choice');
- }
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php
index bf2e4c472be30..efa615abe6ca5 100644
--- a/mod/data/db/upgrade.php
+++ b/mod/data/db/upgrade.php
@@ -1,47 +1,47 @@
.
-defined('MOODLE_INTERNAL') || die();
+/**
+ * This file keeps track of upgrades to the data module
+ *
+ * Sometimes, changes between versions involve
+ * alterations to database structures and other
+ * major things that may break installations.
+ *
+ * The upgrade function in this file will attempt
+ * to perform all the necessary actions to upgrade
+ * your older installation to the current version.
+ *
+ * If there's something it cannot do itself, it
+ * will tell you what you need to do.
+ *
+ * The commands in here will all be database-neutral,
+ * using the methods of database_manager class
+ *
+ * Please do not forget to use upgrade_set_timeout()
+ * before any action that may take longer time to finish.
+ *
+ * @package mod_data
+ * @copyright 2006 Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
function xmldb_data_upgrade($oldversion) {
global $DB;
- $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
- if ($oldversion < 2022081600) {
- // Define key userid (foreign) to be added to data_records.
- $table = new xmldb_table('data_records');
- $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']);
- // Launch add key userid.
- $dbman->add_key($table, $key);
-
- // Data savepoint reached.
- upgrade_mod_savepoint(true, 2022081600, 'data');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
@@ -56,7 +56,7 @@ function xmldb_data_upgrade($oldversion) {
$emptydatas = $DB->get_records_sql($sql);
if (!empty($emptydatas)) {
$dataids = array_keys($emptydatas);
- list($datainsql, $dataparams) = $DB->get_in_or_equal($dataids, SQL_PARAMS_NAMED, 'data');
+ [$datainsql, $dataparams] = $DB->get_in_or_equal($dataids, SQL_PARAMS_NAMED, 'data');
$DB->delete_records_select('data_records', "dataid $datainsql", $dataparams);
}
diff --git a/mod/feedback/db/upgrade.php b/mod/feedback/db/upgrade.php
index fa1bde5661d6b..db9af4ae70b01 100644
--- a/mod/feedback/db/upgrade.php
+++ b/mod/feedback/db/upgrade.php
@@ -39,30 +39,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_feedback_upgrade($oldversion) {
- global $CFG, $DB;
-
- $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
- if ($oldversion < 2022053000) {
- // Define key courseid (foreign) to be added to feedback_completed.
- $table = new xmldb_table('feedback_completed');
- $key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']);
-
- // Launch add key courseid.
- $dbman->add_key($table, $key);
-
- // Feedback savepoint reached.
- upgrade_mod_savepoint(true, 2022053000, 'feedback');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/folder/db/upgrade.php b/mod/folder/db/upgrade.php
index 19e82b0382104..472407fe9a349 100644
--- a/mod/folder/db/upgrade.php
+++ b/mod/folder/db/upgrade.php
@@ -42,33 +42,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_folder_upgrade($oldversion) {
- global $CFG, $DB;
-
- $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
- if ($oldversion < 2021052501) {
-
- // Define field forcedownload to be added to folder.
- $table = new xmldb_table('folder');
- $field = new xmldb_field('forcedownload', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'showdownloadfolder');
-
- // Conditionally launch add field forcedownload.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Folder savepoint reached.
- upgrade_mod_savepoint(true, 2021052501, 'folder');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php
index fd7c5debfed23..f28b2d2f83c6d 100644
--- a/mod/forum/db/upgrade.php
+++ b/mod/forum/db/upgrade.php
@@ -40,139 +40,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_forum_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2020072100) {
- // Add index privatereplyto (not unique) to the forum_posts table.
- $table = new xmldb_table('forum_posts');
- $index = new xmldb_index('privatereplyto', XMLDB_INDEX_NOTUNIQUE, ['privatereplyto']);
-
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- upgrade_mod_savepoint(true, 2020072100, 'forum');
- }
-
- if ($oldversion < 2021101100) {
- // Add custom data to digest tasks to stop duplicates being created after this patch.
- $timenow = time();
-
- $sitetimezone = \core_date::get_server_timezone();
- $servermidnight = usergetmidnight($timenow, $sitetimezone);
- $digesttime = $servermidnight + ($CFG->digestmailtime * 3600);
- if ($digesttime < $timenow) {
- // Digest time is in the past. set for tomorrow.
- $servermidnight = usergetmidnight($timenow + DAYSECS, $sitetimezone);
- }
-
- $customdata = json_encode(['servermidnight' => $servermidnight]);
-
- $params = [
- 'component' => 'mod_forum',
- 'classname' => '\mod_forum\task\send_user_digests',
- 'customdata' => '', // We do not want to overwrite any tasks that already have the custom data.
- ];
-
- $textfield = $DB->sql_compare_text('customdata', 1);
-
- $sql = "component = :component AND classname = :classname AND $textfield = :customdata";
-
- $DB->set_field_select('task_adhoc', 'customdata', $customdata, $sql, $params);
-
- upgrade_mod_savepoint(true, 2021101100, 'forum');
- }
-
- if ($oldversion < 2021101101) {
- // Remove the userid-forumid index as it gets replaces with forumid-userid.
- $table = new xmldb_table('forum_read');
- $index = new xmldb_index('userid-forumid', XMLDB_INDEX_NOTUNIQUE, ['userid', 'forumid']);
-
- // Conditionally launch drop index userid-forumid.
- if ($dbman->index_exists($table, $index)) {
- $dbman->drop_index($table, $index);
- }
-
- // Remove the userid-discussionid index as it gets replaced with discussionid-userid.
- $table = new xmldb_table('forum_read');
- $index = new xmldb_index('userid-discussionid', XMLDB_INDEX_NOTUNIQUE, ['userid', 'discussionid']);
-
- // Conditionally launch drop index userid-discussionid.
- if ($dbman->index_exists($table, $index)) {
- $dbman->drop_index($table, $index);
- }
-
- // Define index userid (not unique) to be added to forum_read.
- $table = new xmldb_table('forum_read');
- $index = new xmldb_index('userid', XMLDB_INDEX_NOTUNIQUE, ['userid']);
-
- // Conditionally launch add index userid.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Build replacement indexes to replace the two dropped earlier.
- // Define index forumid-userid (not unique) to be added to forum_read.
- $table = new xmldb_table('forum_read');
- $index = new xmldb_index('forumid-userid', XMLDB_INDEX_NOTUNIQUE, ['forumid', 'userid']);
-
- // Conditionally launch add index forumid-userid.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Define index discussionid-userid (not unique) to be added to forum_read.
- $table = new xmldb_table('forum_read');
- $index = new xmldb_index('discussionid-userid', XMLDB_INDEX_NOTUNIQUE, ['discussionid', 'userid']);
-
- // Conditionally launch add index discussionid-userid.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Forum savepoint reached.
- upgrade_mod_savepoint(true, 2021101101, 'forum');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022062700) {
- // Unset $CFG->forum_usecoursefullname.
- unset_config('forum_usecoursefullname');
-
- // Define field usecoursefullname to be dropped from forum.
- $table = new xmldb_table('forum');
- $field = new xmldb_field('usecoursefullname');
-
- // Conditionally launch drop field usecoursefullname.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
-
- // Forum savepoint reached.
- upgrade_mod_savepoint(true, 2022062700, 'forum');
- }
-
- if ($oldversion < 2022072900) {
- // Define key usermodified (foreign) to be added to forum_discussions.
- $table = new xmldb_table('forum_discussions');
- $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']);
- // Launch add key usermodified.
- $dbman->add_key($table, $key);
-
- // Forum savepoint reached.
- upgrade_mod_savepoint(true, 2022072900, 'forum');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/glossary/db/upgrade.php b/mod/glossary/db/upgrade.php
index 901c334336d9e..a7d93da22cbff 100644
--- a/mod/glossary/db/upgrade.php
+++ b/mod/glossary/db/upgrade.php
@@ -1,33 +1,45 @@
.
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
+/**
+ * This file keeps track of upgrades to the glossary module
+ *
+ * Sometimes, changes between versions involve
+ * alterations to database structures and other
+ * major things that may break installations.
+ *
+ * The upgrade function in this file will attempt
+ * to perform all the necessary actions to upgrade
+ * your older installation to the current version.
+ *
+ * If there's something it cannot do itself, it
+ * will tell you what you need to do.
+ *
+ * The commands in here will all be database-neutral,
+ * using the methods of database_manager class
+ *
+ * Please do not forget to use upgrade_set_timeout()
+ * before any action that may take longer time to finish.
+ *
+ * @package mod_glossary
+ * @copyright 2006 Eloy Lafuente (stronk7)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+function xmldb_glossary_upgrade($oldversion) {
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/h5pactivity/db/upgrade.php b/mod/h5pactivity/db/upgrade.php
index ac524cb46e00b..46512f2fc95fb 100644
--- a/mod/h5pactivity/db/upgrade.php
+++ b/mod/h5pactivity/db/upgrade.php
@@ -39,8 +39,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Function to upgrade mod_h5pactivity.
* @param int $oldversion the version we are upgrading from
@@ -49,203 +47,6 @@
function xmldb_h5pactivity_upgrade($oldversion) {
global $DB;
- $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
-
- if ($oldversion < 2020032300) {
-
- // Changing the default of field timecreated on table h5pactivity to drop it.
- $table = new xmldb_table('h5pactivity');
- $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'name');
-
- // Launch change of default for field timecreated.
- $dbman->change_field_default($table, $field);
-
- // Changing the default of field timemodified on table h5pactivity to drop it.
- $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'timecreated');
-
- // Launch change of default for field timemodified.
- $dbman->change_field_default($table, $field);
-
- // Define table h5pactivity_attempts to be created.
- $table = new xmldb_table('h5pactivity_attempts');
-
- // Adding fields to table h5pactivity_attempts.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('h5pactivityid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('userid', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('attempt', XMLDB_TYPE_INTEGER, '6', null, XMLDB_NOTNULL, null, '1');
- $table->add_field('rawscore', XMLDB_TYPE_INTEGER, '10', null, null, null, '0');
- $table->add_field('maxscore', XMLDB_TYPE_INTEGER, '10', null, null, null, '0');
-
- // Adding keys to table h5pactivity_attempts.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('fk_h5pactivityid', XMLDB_KEY_FOREIGN, ['h5pactivityid'], 'h5pactivity', ['id']);
- $table->add_key('uq_activityuserattempt', XMLDB_KEY_UNIQUE, ['h5pactivityid', 'userid', 'attempt']);
-
- // Adding indexes to table h5pactivity_attempts.
- $table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, ['timecreated']);
- $table->add_index('h5pactivityid-timecreated', XMLDB_INDEX_NOTUNIQUE, ['h5pactivityid', 'timecreated']);
- $table->add_index('h5pactivityid-userid', XMLDB_INDEX_NOTUNIQUE, ['h5pactivityid', 'userid']);
-
- // Conditionally launch create table for h5pactivity_attempts.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // Define table h5pactivity_attempts_results to be created.
- $table = new xmldb_table('h5pactivity_attempts_results');
-
- // Adding fields to table h5pactivity_attempts_results.
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
- $table->add_field('attemptid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('subcontent', XMLDB_TYPE_CHAR, '128', null, null, null, null);
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
- $table->add_field('interactiontype', XMLDB_TYPE_CHAR, '128', null, null, null, null);
- $table->add_field('description', XMLDB_TYPE_TEXT, null, null, null, null, null);
- $table->add_field('correctpattern', XMLDB_TYPE_TEXT, null, null, null, null, null);
- $table->add_field('response', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
- $table->add_field('additionals', XMLDB_TYPE_TEXT, null, null, null, null, null);
- $table->add_field('rawscore', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
- $table->add_field('maxscore', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
-
- // Adding keys to table h5pactivity_attempts_results.
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
- $table->add_key('fk_attemptid', XMLDB_KEY_FOREIGN, ['attemptid'], 'h5pactivity_attempts', ['id']);
-
- // Adding indexes to table h5pactivity_attempts_results.
- $table->add_index('attemptid-timecreated', XMLDB_INDEX_NOTUNIQUE, ['attemptid', 'timecreated']);
-
- // Conditionally launch create table for h5pactivity_attempts_results.
- if (!$dbman->table_exists($table)) {
- $dbman->create_table($table);
- }
-
- // H5pactivity savepoint reached.
- upgrade_mod_savepoint(true, 2020032300, 'h5pactivity');
- }
-
- if ($oldversion < 2020041400) {
-
- // Define field duration to be added to h5pactivity_attempts.
- $table = new xmldb_table('h5pactivity_attempts');
- $field = new xmldb_field('duration', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'maxscore');
-
- // Conditionally launch add field duration.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field completion to be added to h5pactivity_attempts.
- $field = new xmldb_field('completion', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'duration');
-
- // Conditionally launch add field completion.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field success to be added to h5pactivity_attempts.
- $field = new xmldb_field('success', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'completion');
-
- // Conditionally launch add field success.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field duration to be added to h5pactivity_attempts_results.
- $table = new xmldb_table('h5pactivity_attempts_results');
- $field = new xmldb_field('duration', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'maxscore');
-
- // Conditionally launch add field duration.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field completion to be added to h5pactivity_attempts_results.
- $field = new xmldb_field('completion', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'duration');
-
- // Conditionally launch add field completion.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field success to be added to h5pactivity_attempts_results.
- $field = new xmldb_field('success', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'completion');
-
- // Conditionally launch add field success.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // H5pactivity savepoint reached.
- upgrade_mod_savepoint(true, 2020041400, 'h5pactivity');
- }
-
- if ($oldversion < 2020041401) {
-
- // Define field enabletracking to be added to h5pactivity.
- $table = new xmldb_table('h5pactivity');
- $field = new xmldb_field('enabletracking', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'displayoptions');
-
- // Conditionally launch add field enabletracking.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field grademethod to be added to h5pactivity.
- $field = new xmldb_field('grademethod', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '1', 'enabletracking');
-
- // Conditionally launch add field grademethod.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field scaled to be added to h5pactivity_attempts.
- $table = new xmldb_table('h5pactivity_attempts');
- $field = new xmldb_field('scaled', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0', 'maxscore');
-
- // Conditionally launch add field scaled.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Calculate all scaled values from current attempts.
- $rs = $DB->get_recordset('h5pactivity_attempts');
- foreach ($rs as $record) {
- if (empty($record->maxscore)) {
- continue;
- }
- $record->scaled = $record->rawscore / $record->maxscore;
- $DB->update_record('h5pactivity_attempts', $record);
- }
- $rs->close();
-
- // H5pactivity savepoint reached.
- upgrade_mod_savepoint(true, 2020041401, 'h5pactivity');
- }
-
- if ($oldversion < 2020042202) {
-
- // Define field reviewmode to be added to h5pactivity.
- $table = new xmldb_table('h5pactivity');
- $field = new xmldb_field('reviewmode', XMLDB_TYPE_INTEGER, '4', null, null, null, '1', 'grademethod');
-
- // Conditionally launch add field reviewmode.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // H5pactivity savepoint reached.
- upgrade_mod_savepoint(true, 2020042202, 'h5pactivity');
- }
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
@@ -253,7 +54,6 @@ function xmldb_h5pactivity_upgrade($oldversion) {
// Put any upgrade step following this.
if ($oldversion < 2023042401) {
-
// Remove any orphaned attempt/result records (pointing to non-existing activities).
$DB->delete_records_select('h5pactivity_attempts', 'NOT EXISTS (
SELECT 1 FROM {h5pactivity} h5p WHERE h5p.id = {h5pactivity_attempts}.h5pactivityid
diff --git a/mod/imscp/db/upgrade.php b/mod/imscp/db/upgrade.php
index c39929687772f..ceb73199d81d5 100644
--- a/mod/imscp/db/upgrade.php
+++ b/mod/imscp/db/upgrade.php
@@ -22,21 +22,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Stub for database upgrade.
* @param int $oldversion
*/
function xmldb_imscp_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/label/db/upgrade.php b/mod/label/db/upgrade.php
index dd1fe7a685dd9..7cb218fef8a53 100644
--- a/mod/label/db/upgrade.php
+++ b/mod/label/db/upgrade.php
@@ -42,30 +42,9 @@
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
-defined('MOODLE_INTERNAL') || die;
-
function xmldb_label_upgrade($oldversion) {
global $CFG, $DB;
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022101300) {
- $module = $DB->get_field('modules', 'id', ['name' => 'label']);
- $DB->execute('
- UPDATE {course_modules}
- SET visible = 0, visibleoncoursepage = 1
- WHERE module = :module
- AND visible = 1
- AND visibleoncoursepage = 0',
- ['module' => $module]
- );
- upgrade_mod_savepoint(true, 2022101300, 'label');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/lesson/db/upgrade.php b/mod/lesson/db/upgrade.php
index 018f3721b9655..21afebb6ca788 100644
--- a/mod/lesson/db/upgrade.php
+++ b/mod/lesson/db/upgrade.php
@@ -40,8 +40,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 o
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
*
* @global stdClass $CFG
@@ -50,14 +48,6 @@
* @return bool
*/
function xmldb_lesson_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/lti/db/upgrade.php b/mod/lti/db/upgrade.php
index f4663dd168953..01f94cb5f95a9 100644
--- a/mod/lti/db/upgrade.php
+++ b/mod/lti/db/upgrade.php
@@ -45,8 +45,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
- defined('MOODLE_INTERNAL') || die;
-
/**
* xmldb_lti_upgrade is the function that upgrades
* the lti module database when is needed
@@ -63,51 +61,6 @@ function xmldb_lti_upgrade($oldversion) {
$dbman = $DB->get_manager();
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
-
- // Changing type of field instructorcustomparameters on table lti to text.
- $table = new xmldb_table('lti');
- $field = new xmldb_field('instructorcustomparameters', XMLDB_TYPE_TEXT, null, null, null, null, null,
- 'instructorchoiceallowsetting');
-
- // Launch change of type for field value.
- $dbman->change_field_type($table, $field);
-
- // Lti savepoint reached.
- upgrade_mod_savepoint(true, 2021052501, 'lti');
- }
-
- if ($oldversion < 2022032900) {
- // This option 'Public key type' was added in MDL-66920, but no value was set for existing 1.3 tools.
- // Set a default of 'RSA Key' for those LTI 1.3 tools without a value, representing the only key type they
- // could use at the time of their creation. Existing tools which have since been resaved will not be impacted.
- $sql = "SELECT t.id
- FROM {lti_types} t
- LEFT JOIN {lti_types_config} tc
- ON (tc.typeid = t.id AND tc.name = :typename)
- WHERE t.ltiversion = :ltiversion
- AND tc.value IS NULL";
- $params = ['typename' => 'keytype', 'ltiversion' => '1.3.0'];
- $recordset = $DB->get_recordset_sql($sql, $params);
- foreach ($recordset as $record) {
- $DB->insert_record('lti_types_config', (object) [
- 'typeid' => $record->id,
- 'name' => 'keytype',
- 'value' => 'RSA_KEY'
- ]);
- }
- $recordset->close();
-
- // Lti savepoint reached.
- upgrade_mod_savepoint(true, 2022032900, 'lti');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
@@ -115,7 +68,6 @@ function xmldb_lti_upgrade($oldversion) {
// Put any upgrade step following this.
if ($oldversion < 2023070501) {
-
// Define table lti_types_categories to be created.
$table = new xmldb_table('lti_types_categories');
diff --git a/mod/lti/service/gradebookservices/db/upgrade.php b/mod/lti/service/gradebookservices/db/upgrade.php
index c98dc952dd7ac..6f811f46bc5ed 100644
--- a/mod/lti/service/gradebookservices/db/upgrade.php
+++ b/mod/lti/service/gradebookservices/db/upgrade.php
@@ -41,8 +41,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
- defined('MOODLE_INTERNAL') || die;
-
/**
* xmldb_ltiservice_gradebookservices_upgrade is the function that upgrades
* the gradebook lti service subplugin database when is needed.
@@ -55,79 +53,6 @@
* @return boolean
*/
function xmldb_ltiservice_gradebookservices_upgrade($oldversion) {
- global $CFG, $DB, $OUTPUT;
-
- $dbman = $DB->get_manager();
-
- if ($oldversion < 2020042401) {
- // Define field typeid to be added to lti_tool_settings.
- $table = new xmldb_table('ltiservice_gradebookservices');
- $field = new xmldb_field('resourceid', XMLDB_TYPE_CHAR, "512", null, null, null, null);
-
- // Conditionally launch add field typeid.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2020042401, 'ltiservice', 'gradebookservices');
- }
-
- if ($oldversion < 2020042402) {
- // Now that we have added the new column let's migrate it'
- // Prior implementation was storing the resourceid under the grade item idnumber, so moving it to lti_gradebookservices.
- // We only care for mod/lti grade items as manual columns would already have a matching gradebookservices record.
-
- $DB->execute("INSERT INTO {ltiservice_gradebookservices}
- (gradeitemid, courseid, typeid, ltilinkid, resourceid, baseurl, toolproxyid)
- SELECT gi.id, courseid, lti.typeid, lti.id, gi.idnumber, t.baseurl, t.toolproxyid
- FROM {grade_items} gi
- JOIN {lti} lti ON lti.id=gi.iteminstance AND gi.itemtype='mod' AND gi.itemmodule='lti'
- JOIN {lti_types} t ON t.id = lti.typeid
- WHERE gi.id NOT IN ( SELECT gradeitemid
- FROM {ltiservice_gradebookservices} )
- AND gi.idnumber IS NOT NULL
- AND gi.idnumber <> ''");
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2020042402, 'ltiservice', 'gradebookservices');
- }
-
- if ($oldversion < 2020042403) {
- // Here updating the resourceid of pre-existing lti_gradebookservices.
- $DB->execute("UPDATE {ltiservice_gradebookservices}
- SET resourceid = (SELECT idnumber FROM {grade_items} WHERE id=gradeitemid)
- WHERE gradeitemid in (SELECT id FROM {grade_items}
- WHERE ((itemtype='mod' AND itemmodule='lti') OR itemtype='manual')
- AND idnumber IS NOT NULL
- AND idnumber <> '')
- AND (resourceid is null OR resourceid = '')");
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2020042403, 'ltiservice', 'gradebookservices');
- }
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2022051900) {
- $table = new xmldb_table('ltiservice_gradebookservices');
- $field = new xmldb_field('subreviewurl', XMLDB_TYPE_TEXT, null, null, null, null, null);
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
- $field = new xmldb_field('subreviewparams', XMLDB_TYPE_TEXT, null, null, null, null, null);
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Lti savepoint reached.
- upgrade_plugin_savepoint(true, 2022051900, 'ltiservice', 'gradebookservices');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/page/db/upgrade.php b/mod/page/db/upgrade.php
index 25cb725e36124..95a862e44e701 100644
--- a/mod/page/db/upgrade.php
+++ b/mod/page/db/upgrade.php
@@ -42,17 +42,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
-
function xmldb_page_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/quiz/accessrule/seb/db/upgrade.php b/mod/quiz/accessrule/seb/db/upgrade.php
index 2cb5cea4b1528..f6529564f8f69 100644
--- a/mod/quiz/accessrule/seb/db/upgrade.php
+++ b/mod/quiz/accessrule/seb/db/upgrade.php
@@ -34,15 +34,6 @@
* @return bool Result.
*/
function xmldb_quizaccess_seb_upgrade($oldversion) {
- global $DB;
- $dbman = $DB->get_manager();
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/quiz/db/upgrade.php b/mod/quiz/db/upgrade.php
index 808cbda40a772..4f12c051706fa 100644
--- a/mod/quiz/db/upgrade.php
+++ b/mod/quiz/db/upgrade.php
@@ -22,7 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-
/**
* Quiz module upgrade function.
* @param string $oldversion the version we are upgrading from.
@@ -31,134 +30,6 @@ function xmldb_quiz_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2020061501) {
-
- // Define field completionminattempts to be added to quiz.
- $table = new xmldb_table('quiz');
- $field = new xmldb_field('completionminattempts', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0',
- 'completionpass');
-
- // Conditionally launch add field completionminattempts.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Quiz savepoint reached.
- upgrade_mod_savepoint(true, 2020061501, 'quiz');
- }
-
- if ($oldversion < 2021052503) {
- $table = new xmldb_table('quiz');
- $field = new xmldb_field('completionpass');
-
- if ($dbman->field_exists($table, $field)) {
- $sql = "SELECT q.id, m.id as quizid " .
- "FROM {quiz} q " .
- "INNER JOIN {course_modules} cm ON cm.instance = q.id " .
- "INNER JOIN {modules} m ON m.id = cm.module " .
- "WHERE m.name = :name AND q.completionpass = :completionpass";
-
- /** @var moodle_recordset $records */
- $records = $DB->get_recordset_sql($sql, ['name' => 'quiz', 'completionpass' => 1], 0, 1000);
- while ($records->valid()) {
- $quizmodule = null;
- foreach ($records as $record) {
- $ids[] = $record->id;
- $quizmodule = $record->quizid;
- }
-
- if ($ids) {
- list($insql, $params) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED);
- $DB->set_field_select('course_modules', 'completionpassgrade', 1,
- "module = :quiz AND instance $insql", $params + ['quiz' => $quizmodule]);
-
- // Reset the value so it doesn't get picked on the next run. The field will be dropped later.
- $DB->set_field_select('quiz', 'completionpass', 0, "id $insql", $params);
-
- // Get the next batch of records.
- $records = $DB->get_recordset_sql($sql, ['name' => 'quiz', 'completionpass' => 1], 0, 1000);
- }
- }
- $records->close();
-
- // We have completed our checks. Drop the field.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
- }
-
- upgrade_mod_savepoint(true, 2021052503, 'quiz');
- }
-
- if ($oldversion < 2021101900) {
-
- // Define field gradednotificationsenttime to be added to quiz_attempts.
- $table = new xmldb_table('quiz_attempts');
- $field = new xmldb_field('gradednotificationsenttime', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'sumgrades');
-
- // Conditionally launch add field gradednotificationsenttime.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
-
- $DB->execute('UPDATE {quiz_attempts} SET gradednotificationsenttime = timefinish');
- }
-
- // Quiz savepoint reached.
- upgrade_mod_savepoint(true, 2021101900, 'quiz');
- }
-
- if ($oldversion < 2022020300) {
- // Define table quiz_slot_tags to be dropped.
- $table = new xmldb_table('quiz_slot_tags');
-
- // Conditionally launch drop table for quiz_slot_tags.
- if ($dbman->table_exists($table)) {
- $dbman->drop_table($table);
- }
-
- // Define fields to be dropped from quiz_slots.
- $table = new xmldb_table('quiz_slots');
-
- // Define key questionid (foreign) to be dropped form quiz_slots.
- $key = new xmldb_key('questionid', XMLDB_KEY_FOREIGN, ['questionid'], 'question', ['id']);
-
- // Launch drop key questionid.
- $dbman->drop_key($table, $key);
-
- // Define key questioncategoryid (foreign) to be dropped form quiz_slots.
- $key = new xmldb_key('questioncategoryid', XMLDB_KEY_FOREIGN, ['questioncategoryid'], 'question_categories', ['id']);
-
- // Launch drop key questioncategoryid.
- $dbman->drop_key($table, $key);
-
- $field = new xmldb_field('questionid');
- // Conditionally launch drop field questionid.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
-
- $field = new xmldb_field('questioncategoryid');
- // Conditionally launch drop field questioncategoryid.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
-
- $field = new xmldb_field('includingsubcategories');
- // Conditionally launch drop field includingsubcategories.
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
-
- // Quiz savepoint reached.
- upgrade_mod_savepoint(true, 2022020300, 'quiz');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
@@ -180,7 +51,6 @@ function xmldb_quiz_upgrade($oldversion) {
// Put any upgrade step following this.
if ($oldversion < 2023042401) {
-
// Define field reviewmaxmarks to be added to quiz.
$table = new xmldb_table('quiz');
$field = new xmldb_field('reviewmaxmarks', XMLDB_TYPE_INTEGER, '6', null, XMLDB_NOTNULL, null, '0', 'reviewcorrectness');
diff --git a/mod/quiz/report/overview/db/upgrade.php b/mod/quiz/report/overview/db/upgrade.php
index 895338375e031..621d4d9adde1c 100644
--- a/mod/quiz/report/overview/db/upgrade.php
+++ b/mod/quiz/report/overview/db/upgrade.php
@@ -22,21 +22,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Quiz overview report upgrade function.
* @param number $oldversion
*/
function xmldb_quiz_overview_upgrade($oldversion) {
- global $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/quiz/report/statistics/db/upgrade.php b/mod/quiz/report/statistics/db/upgrade.php
index 989a64236e09d..fefbfbaf371eb 100644
--- a/mod/quiz/report/statistics/db/upgrade.php
+++ b/mod/quiz/report/statistics/db/upgrade.php
@@ -22,20 +22,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Quiz statistics report upgrade code.
*/
function xmldb_quiz_statistics_upgrade($oldversion) {
- global $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/resource/db/upgrade.php b/mod/resource/db/upgrade.php
index c9111cb3e90f5..23f7fa45792b9 100644
--- a/mod/resource/db/upgrade.php
+++ b/mod/resource/db/upgrade.php
@@ -42,17 +42,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
-
function xmldb_resource_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/scorm/db/upgrade.php b/mod/scorm/db/upgrade.php
index 397b00a79ecd8..5ef2de349f270 100644
--- a/mod/scorm/db/upgrade.php
+++ b/mod/scorm/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* @global moodle_database $DB
* @param int $oldversion
@@ -34,21 +32,6 @@ function xmldb_scorm_upgrade($oldversion) {
$dbman = $DB->get_manager();
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
- $table = new xmldb_table('scorm');
- $field = new xmldb_field('displayactivityname');
- if ($dbman->field_exists($table, $field)) {
- $dbman->drop_field($table, $field);
- }
- upgrade_mod_savepoint(true, 2021052501, 'scorm');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
@@ -135,15 +118,16 @@ function xmldb_scorm_upgrade($oldversion) {
$trans->allow_commit();
// Scorm savepoint reached.
upgrade_mod_savepoint(true, 2023042402, 'scorm');
-
}
if ($oldversion < 2023042403) {
// Now store all translated data in the scorm_scoes_value table.
$total = $DB->count_records('scorm_scoes_track');
if ($total > 500000) {
// This site has a large number of user track records, lets warn that this next part may take some time.
- $notification = new \core\output\notification(get_string('largetrackupgrade', 'scorm', format_float($total, 0)),
- \core\output\notification::NOTIFY_WARNING);
+ $notification = new \core\output\notification(
+ get_string('largetrackupgrade', 'scorm', format_float($total, 0)),
+ \core\output\notification::NOTIFY_WARNING
+ );
$notification->set_show_closebutton(false);
echo $OUTPUT->render($notification);
}
diff --git a/mod/survey/db/upgrade.php b/mod/survey/db/upgrade.php
index af8dcc5bef9ea..cac5ba4010d99 100644
--- a/mod/survey/db/upgrade.php
+++ b/mod/survey/db/upgrade.php
@@ -1,35 +1,45 @@
.
+
+/**
+ * This file keeps track of upgrades to the survey module
+ *
+ * Sometimes, changes between versions involve
+ * alterations to database structures and other
+ * major things that may break installations.
+ *
+ * The upgrade function in this file will attempt
+ * to perform all the necessary actions to upgrade
+ * your older installation to the current version.
+ *
+ * If there's something it cannot do itself, it
+ * will tell you what you need to do.
+ *
+ * The commands in here will all be database-neutral,
+ * using the methods of database_manager class
+ *
+ * Please do not forget to use upgrade_set_timeout()
+ * before any action that may take longer time to finish.
+ *
+ * @package mod_survey
+ * @copyright 2006 Eloy Lafuente (stronk7)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
function xmldb_survey_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/url/db/upgrade.php b/mod/url/db/upgrade.php
index 02b586b83d5a4..5655555b099c4 100644
--- a/mod/url/db/upgrade.php
+++ b/mod/url/db/upgrade.php
@@ -42,17 +42,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
-
function xmldb_url_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/wiki/db/upgrade.php b/mod/wiki/db/upgrade.php
index 886a63f4fef93..9689617ff3712 100644
--- a/mod/wiki/db/upgrade.php
+++ b/mod/wiki/db/upgrade.php
@@ -35,17 +35,7 @@
*
*/
-defined('MOODLE_INTERNAL') || die();
-
function xmldb_wiki_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/workshop/db/upgrade.php b/mod/workshop/db/upgrade.php
index 728956181108c..0888187c5b9fc 100644
--- a/mod/workshop/db/upgrade.php
+++ b/mod/workshop/db/upgrade.php
@@ -23,8 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Performs upgrade of the database structure and data
*
@@ -35,29 +33,6 @@
* @return bool result
*/
function xmldb_workshop_upgrade($oldversion) {
- global $DB;
-
- $dbman = $DB->get_manager();
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
-
- // Changing nullability of field grade on table workshop_grades to null.
- $table = new xmldb_table('workshop_grades');
- $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, 'dimensionid');
-
- // Launch change of nullability for field grade.
- $dbman->change_field_notnull($table, $field);
-
- // Workshop savepoint reached.
- upgrade_mod_savepoint(true, 2021052501, 'workshop');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/workshop/form/accumulative/db/upgrade.php b/mod/workshop/form/accumulative/db/upgrade.php
index 6caeae771e7de..2eccedd08dd8b 100644
--- a/mod/workshop/form/accumulative/db/upgrade.php
+++ b/mod/workshop/form/accumulative/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Performs upgrade of the database structure and data
*
@@ -31,14 +29,6 @@
* @return bool true
*/
function xmldb_workshopform_accumulative_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/workshop/form/comments/db/upgrade.php b/mod/workshop/form/comments/db/upgrade.php
index c08d0ef941848..75ea0c2027e78 100644
--- a/mod/workshop/form/comments/db/upgrade.php
+++ b/mod/workshop/form/comments/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Performs upgrade of the database structure and data
*
@@ -31,14 +29,6 @@
* @return bool true
*/
function xmldb_workshopform_comments_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/workshop/form/numerrors/db/upgrade.php b/mod/workshop/form/numerrors/db/upgrade.php
index 775ca03af6cc9..7d925af09500b 100644
--- a/mod/workshop/form/numerrors/db/upgrade.php
+++ b/mod/workshop/form/numerrors/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Performs upgrade of the database structure and data
*
@@ -31,14 +29,6 @@
* @return bool true
*/
function xmldb_workshopform_numerrors_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/mod/workshop/form/rubric/db/upgrade.php b/mod/workshop/form/rubric/db/upgrade.php
index 70ba870d111fd..4f14d83542030 100644
--- a/mod/workshop/form/rubric/db/upgrade.php
+++ b/mod/workshop/form/rubric/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Performs upgrade of the database structure and data
*
@@ -31,14 +29,6 @@
* @return bool true
*/
function xmldb_workshopform_rubric_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/payment/gateway/paypal/db/upgrade.php b/payment/gateway/paypal/db/upgrade.php
index dc6c1a635b991..aa623ec631176 100644
--- a/payment/gateway/paypal/db/upgrade.php
+++ b/payment/gateway/paypal/db/upgrade.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade the plugin.
*
@@ -47,12 +45,6 @@ function xmldb_paygw_paypal_upgrade(int $oldversion): bool {
upgrade_plugin_savepoint(true, 2021052501, 'paygw', 'paypal');
}
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.1.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.2.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 0a43b7d2da59b..478ac57403f6c 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -1,5 +1,5 @@
-
+
diff --git a/portfolio/googledocs/db/upgrade.php b/portfolio/googledocs/db/upgrade.php
index 07f4209adbfcb..152fb172a8360 100644
--- a/portfolio/googledocs/db/upgrade.php
+++ b/portfolio/googledocs/db/upgrade.php
@@ -14,21 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die();
-
/**
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_portfolio_googledocs_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/behaviour/manualgraded/db/upgrade.php b/question/behaviour/manualgraded/db/upgrade.php
index 2950f398f298e..5488a87442d4e 100644
--- a/question/behaviour/manualgraded/db/upgrade.php
+++ b/question/behaviour/manualgraded/db/upgrade.php
@@ -22,20 +22,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Manual graded question behaviour upgrade code.
*/
function xmldb_qbehaviour_manualgraded_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/type/calculated/db/upgrade.php b/question/type/calculated/db/upgrade.php
index 9bb5d84066cb4..3a3e941ffd52a 100644
--- a/question/type/calculated/db/upgrade.php
+++ b/question/type/calculated/db/upgrade.php
@@ -23,21 +23,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the calculated question type.
* @param int $oldversion the version we are upgrading from.
*/
function xmldb_qtype_calculated_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/type/ddmarker/db/upgrade.php b/question/type/ddmarker/db/upgrade.php
index 37cbb472c78b3..6b4b19a47c7da 100644
--- a/question/type/ddmarker/db/upgrade.php
+++ b/question/type/ddmarker/db/upgrade.php
@@ -22,23 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
-
/**
* Upgrade code for the ddmarker question type.
* @param int $oldversion the version we are upgrading from.
* @return bool
*/
function xmldb_qtype_ddmarker_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/type/essay/db/upgrade.php b/question/type/essay/db/upgrade.php
index 22acea9d8e795..2977627f81f53 100644
--- a/question/type/essay/db/upgrade.php
+++ b/question/type/essay/db/upgrade.php
@@ -23,63 +23,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the essay question type.
* @param int $oldversion the version we are upgrading from.
*/
function xmldb_qtype_essay_upgrade($oldversion) {
- global $CFG, $DB;
-
- $dbman = $DB->get_manager();
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
-
- // Define field maxbytes to be added to qtype_essay_options.
- $table = new xmldb_table('qtype_essay_options');
- $field = new xmldb_field('maxbytes', XMLDB_TYPE_INTEGER, '10', null,
- XMLDB_NOTNULL, null, '0', 'responsetemplateformat');
-
- // Conditionally launch add field maxbytes.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Essay savepoint reached.
- upgrade_plugin_savepoint(true, 2021052501, 'qtype', 'essay');
- }
-
- if ($oldversion < 2021052502) {
-
- // Define field minwordlimit to be added to qtype_essay_options.
- $table = new xmldb_table('qtype_essay_options');
- $field = new xmldb_field('minwordlimit', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'responsefieldlines');
-
- // Conditionally launch add field minwordlimit.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Define field maxwordlimit to be added to qtype_essay_options.
- $table = new xmldb_table('qtype_essay_options');
- $field = new xmldb_field('maxwordlimit', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'minwordlimit');
-
- // Conditionally launch add field maxwordlimit.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Essay savepoint reached.
- upgrade_plugin_savepoint(true, 2021052502, 'qtype', 'essay');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/type/match/db/upgrade.php b/question/type/match/db/upgrade.php
index 8fc26851692e3..e6d54ec1d3927 100644
--- a/question/type/match/db/upgrade.php
+++ b/question/type/match/db/upgrade.php
@@ -22,21 +22,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the matching question type.
* @param int $oldversion the version we are upgrading from.
*/
function xmldb_qtype_match_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/type/multianswer/db/upgrade.php b/question/type/multianswer/db/upgrade.php
index fbde327a9d1de..49c4258dfa545 100644
--- a/question/type/multianswer/db/upgrade.php
+++ b/question/type/multianswer/db/upgrade.php
@@ -23,21 +23,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the multi-answer question type.
* @param int $oldversion the version we are upgrading from.
*/
function xmldb_qtype_multianswer_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/type/multichoice/db/upgrade.php b/question/type/multichoice/db/upgrade.php
index 5689f1413a871..3ff8a9e70cda8 100644
--- a/question/type/multichoice/db/upgrade.php
+++ b/question/type/multichoice/db/upgrade.php
@@ -23,21 +23,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the multiple choice question type.
* @param int $oldversion the version we are upgrading from.
*/
function xmldb_qtype_multichoice_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/type/numerical/db/upgrade.php b/question/type/numerical/db/upgrade.php
index 8fe65845a839d..0e3dee5a086a3 100644
--- a/question/type/numerical/db/upgrade.php
+++ b/question/type/numerical/db/upgrade.php
@@ -23,21 +23,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the numerical question type.
* @param int $oldversion the version we are upgrading from.
*/
function xmldb_qtype_numerical_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/type/random/db/upgrade.php b/question/type/random/db/upgrade.php
index fd0d328609328..625a657d49da6 100644
--- a/question/type/random/db/upgrade.php
+++ b/question/type/random/db/upgrade.php
@@ -22,21 +22,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the random question type.
* @param int $oldversion the version we are upgrading from.
*/
function xmldb_qtype_random_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/type/randomsamatch/db/upgrade.php b/question/type/randomsamatch/db/upgrade.php
index e37cad9e7156d..57751b367cf72 100644
--- a/question/type/randomsamatch/db/upgrade.php
+++ b/question/type/randomsamatch/db/upgrade.php
@@ -22,21 +22,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the random short answer matching question type.
* @param int $oldversion the version we are upgrading from.
*/
function xmldb_qtype_randomsamatch_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/type/shortanswer/db/upgrade.php b/question/type/shortanswer/db/upgrade.php
index c0dcd2739ebe2..6c92a152463c7 100644
--- a/question/type/shortanswer/db/upgrade.php
+++ b/question/type/shortanswer/db/upgrade.php
@@ -23,21 +23,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade code for the essay question type.
* @param int $oldversion the version we are upgrading from.
*/
function xmldb_qtype_shortanswer_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/question/type/truefalse/db/upgrade.php b/question/type/truefalse/db/upgrade.php
index 17ef0f1315380..b8b7eac8b7ce3 100644
--- a/question/type/truefalse/db/upgrade.php
+++ b/question/type/truefalse/db/upgrade.php
@@ -29,25 +29,6 @@
* @return bool
*/
function xmldb_qtype_truefalse_upgrade(int $oldversion): bool {
- global $DB;
-
- $dbman = $DB->get_manager();
-
- if ($oldversion < 2022071900) {
-
- // Define field showstandardinstruction to be added to question_truefalse.
- $table = new xmldb_table('question_truefalse');
- $field = new xmldb_field('showstandardinstruction', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '1', 'falseanswer');
-
- // Conditionally launch add field showstandardinstruction.
- if (!$dbman->field_exists($table, $field)) {
- $dbman->add_field($table, $field);
- }
-
- // Truefalse savepoint reached.
- upgrade_plugin_savepoint(true, 2022071900, 'qtype', 'truefalse');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/repository/dropbox/db/upgrade.php b/repository/dropbox/db/upgrade.php
index 8442c090fdcd4..8482a39122c23 100644
--- a/repository/dropbox/db/upgrade.php
+++ b/repository/dropbox/db/upgrade.php
@@ -14,64 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die();
-
/**
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_repository_dropbox_upgrade($oldversion) {
- global $CFG, $DB;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- if ($oldversion < 2021052501) {
- $key = get_config('dropbox', 'dropbox_key');
- $secret = get_config('dropbox', 'dropbox_secret');
-
- if ($key && $secret) {
- $params = [
- 'name' => 'Dropbox',
- 'clientid' => $key,
- 'clientsecret' => $secret,
- 'loginparamsoffline' => 'token_access_type=offline',
- 'image' => '',
- 'showonloginpage' => 0, // Internal services only.
- ];
- $record = $DB->get_record('oauth2_issuer', ['name' => 'Dropbox'], 'id');
- if (!$record) {
- $params = array_merge($params, [
- 'timecreated' => time(),
- 'timemodified' => time(),
- 'usermodified' => time(),
- 'baseurl' => 0,
- 'sortorder' => '',
- 'loginparams' => '',
- 'requireconfirmation' => 1,
- 'alloweddomains' => '',
- 'loginscopes' => 'openid profile email',
- 'loginscopesoffline' => 'openid profile email',
- ]);
- $id = $DB->insert_record('oauth2_issuer', $params);
- } else {
- $id = $record->id;
- $params['id'] = $id;
- $DB->update_record('oauth2_issuer', $params);
- }
-
- set_config('dropbox_issuerid', $id, 'dropbox');
- unset_config('dropbox_key', 'dropbox');
- unset_config('dropbox_secret', 'dropbox');
- }
-
- // Dropbox savepoint reached.
- upgrade_plugin_savepoint(true, 2021052501, 'repository', 'dropbox');
- }
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/repository/flickr/db/upgrade.php b/repository/flickr/db/upgrade.php
index bcd44566361e6..12f4d3dedb146 100644
--- a/repository/flickr/db/upgrade.php
+++ b/repository/flickr/db/upgrade.php
@@ -23,8 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die();
-
/**
* Execute repository_flickr upgrade from the given old version.
*
@@ -32,14 +30,6 @@
* @return bool
*/
function xmldb_repository_flickr_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/repository/googledocs/db/upgrade.php b/repository/googledocs/db/upgrade.php
index c105298276e29..789a53c9a1c3b 100644
--- a/repository/googledocs/db/upgrade.php
+++ b/repository/googledocs/db/upgrade.php
@@ -14,21 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die();
-
/**
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_repository_googledocs_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/repository/onedrive/db/upgrade.php b/repository/onedrive/db/upgrade.php
index 821f4392e6a39..283a29e10dc2a 100644
--- a/repository/onedrive/db/upgrade.php
+++ b/repository/onedrive/db/upgrade.php
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-defined('MOODLE_INTERNAL') || die();
-
/**
* Upgrade this plugin.
*
@@ -24,14 +22,6 @@
* @return bool result
*/
function xmldb_repository_onedrive_upgrade($oldversion) {
- global $CFG;
-
- // Automatically generated Moodle v3.9.0 release upgrade line.
- // Put any upgrade step following this.
-
- // Automatically generated Moodle v4.0.0 release upgrade line.
- // Put any upgrade step following this.
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
diff --git a/search/engine/simpledb/db/upgrade.php b/search/engine/simpledb/db/upgrade.php
index aae62d806465c..0ac5d8ffc64ad 100644
--- a/search/engine/simpledb/db/upgrade.php
+++ b/search/engine/simpledb/db/upgrade.php
@@ -27,42 +27,6 @@
* @param int $oldversion the version we are upgrading from.
*/
function xmldb_search_simpledb_upgrade($oldversion = 0) {
- global $DB;
-
- $dbman = $DB->get_manager();
-
- if ($oldversion < 2022050400) {
-
- $table = new xmldb_table('search_simpledb_index');
-
- // Define index areaid (not unique) to be added to search_simpledb_index.
- $index = new xmldb_index('contextid', XMLDB_INDEX_NOTUNIQUE, ['contextid']);
-
- // Conditionally launch add index contextid.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Define index courseid (not unique) to be added to search_simpledb_index.
- $index = new xmldb_index('courseid', XMLDB_INDEX_NOTUNIQUE, ['courseid']);
-
- // Conditionally launch add index courseid.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Define index areaid (not unique) to be added to search_simpledb_index.
- $index = new xmldb_index('areaid', XMLDB_INDEX_NOTUNIQUE, ['areaid']);
-
- // Conditionally launch add index areaid.
- if (!$dbman->index_exists($table, $index)) {
- $dbman->add_index($table, $index);
- }
-
- // Simpledb savepoint reached.
- upgrade_plugin_savepoint(true, 2022050400, 'search', 'simpledb');
- }
-
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.