From 14557b5a849430211c161cde9cbd0e8186ee4dfd Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 09:41:46 +0100 Subject: [PATCH 01/14] MDL-65809 environment: 3.9 base information This is a direct copy of the 3.8 branch to have changes under control easier in next commits. --- admin/environment.xml | 181 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/admin/environment.xml b/admin/environment.xml index 16b7402d357..3cc5e8d6b05 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -2982,4 +2982,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 70f279bec920d935245bcef3541e661141669fd9 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 09:43:56 +0100 Subject: [PATCH 02/14] MDL-65809 environment: 3.5 (LTS) required --- admin/environment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/environment.xml b/admin/environment.xml index 3cc5e8d6b05..451de914c1e 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -2982,7 +2982,7 @@ - + From d83a2d7f55b78be2f6c93bd1999f4032292755af Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 09:46:21 +0100 Subject: [PATCH 03/14] MDL-65809 environment: mariadb requirement up to 10.2 --- admin/environment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/environment.xml b/admin/environment.xml index 451de914c1e..60bc1b9d8f0 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -2989,7 +2989,7 @@ - + From 2e151145e8127239294badaf4cd53521f8ce66ff Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 09:47:26 +0100 Subject: [PATCH 04/14] MDL-65809 environment: postgres requirement up to 9.5 --- admin/environment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/environment.xml b/admin/environment.xml index 60bc1b9d8f0..96cea4f3770 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -2991,7 +2991,7 @@ - + From 64f2200a7dd1d45d6d9a43249d15e5bd66492bf6 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 09:49:02 +0100 Subject: [PATCH 05/14] MDL-65809 environment: PHP 7.2 required --- admin/environment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/environment.xml b/admin/environment.xml index 96cea4f3770..55a24fc63d1 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -2995,7 +2995,7 @@ - + From ad7fcff3b74954e03ebed5d2934f56788a3a91de Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 09:50:53 +0100 Subject: [PATCH 06/14] MDL-65809 environment: mbstring extension required --- admin/environment.xml | 4 ++-- lang/en/admin.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/admin/environment.xml b/admin/environment.xml index 55a24fc63d1..6f6fb8141f2 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -3008,9 +3008,9 @@ - + - + diff --git a/lang/en/admin.php b/lang/en/admin.php index 3ec73135297..50e3384141d 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -769,6 +769,7 @@ $string['maxeditingtime'] = 'Maximum time to edit posts'; $string['maxusersperpage'] = ' Maximum users per page'; $string['configmaxusersperpage'] = 'Maximum number of users displayed within user selector in course, group, cohort, webservice etc.'; $string['mbstringrecommended'] = 'Installing the optional MBSTRING library is highly recommended in order to improve site performance, particularly if your site is supporting non-Latin languages.'; +$string['mbstringrequired'] = 'Installing the MBSTRING library is required in order to improve site performance, particularly if your site is supporting non-Latin languages.'; $string['mediapluginavi'] = 'Enable .avi filter'; $string['mediapluginflv'] = 'Enable .flv filter'; $string['mediapluginimg'] = 'Enable auto-embedding of linked images'; From c23030695741e7c0e4a490c750b38364feca5f43 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 11:52:23 +0100 Subject: [PATCH 07/14] MDL-65809 upgrade: remove upgrade_fix_block_instance_configuration The upgrade_fix_block_instance_configuration() function was used only by deleted upgrade steps so it's safe to proceed with straight deletion, considering it internal. Deletion has been documented in corresponding upgrade.txt files. --- admin/upgrade.txt | 5 +++++ lib/db/upgrade.php | 8 -------- lib/db/upgradelib.php | 21 --------------------- lib/tests/upgradelib_test.php | 30 ------------------------------ 4 files changed, 5 insertions(+), 59 deletions(-) diff --git a/admin/upgrade.txt b/admin/upgrade.txt index 68f18eb1110..9d0e28d89d3 100644 --- a/admin/upgrade.txt +++ b/admin/upgrade.txt @@ -1,5 +1,10 @@ This files describes API changes in /admin/*. +=== 3.9 === + +* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info: + - upgrade_fix_block_instance_configuration() + === 3.8 === * Admin setting "Open to Google" (opentogoogle) has been renamed to the more generic "Open to search engines" (opentowebcrawlers). diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 91a1a20b208..5b357ff6e19 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1526,14 +1526,6 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2018020500.00); } - if ($oldversion < 2018022800.01) { - // Fix old block configurations that use the deprecated (and now removed) object class. - upgrade_fix_block_instance_configuration(); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018022800.01); - } - if ($oldversion < 2018022800.02) { // Define index taggeditem (unique) to be dropped form tag_instance. $table = new xmldb_table('tag_instance'); diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php index 89417ae9f22..90e6ce06722 100644 --- a/lib/db/upgradelib.php +++ b/lib/db/upgradelib.php @@ -503,27 +503,6 @@ function upgrade_block_positions() { $DB->execute($sql, ['']); } -/** - * Fix configdata in block instances that are using the old object class that has been removed (deprecated). - */ -function upgrade_fix_block_instance_configuration() { - global $DB; - - $sql = "SELECT * - FROM {block_instances} - WHERE " . $DB->sql_isnotempty('block_instances', 'configdata', true, true); - $blockinstances = $DB->get_recordset_sql($sql); - foreach ($blockinstances as $blockinstance) { - $configdata = base64_decode($blockinstance->configdata); - list($updated, $configdata) = upgrade_fix_serialized_objects($configdata); - if ($updated) { - $blockinstance->configdata = base64_encode($configdata); - $DB->update_record('block_instances', $blockinstance); - } - } - $blockinstances->close(); -} - /** * Provides a way to check and update a serialized string that uses the deprecated object class. * diff --git a/lib/tests/upgradelib_test.php b/lib/tests/upgradelib_test.php index 3aa0ecc4e99..dde95796083 100644 --- a/lib/tests/upgradelib_test.php +++ b/lib/tests/upgradelib_test.php @@ -890,36 +890,6 @@ class core_upgradelib_testcase extends advanced_testcase { ]; } - /** - * Check that entries in the block_instances table are coverted over correctly. - * - * @dataProvider encoded_strings_dataprovider - * @param string $original The original base64_encoded block config setting. - * @param string $expected The expected base64_encoded block config setting. - */ - public function test_upgrade_fix_block_instance_configuration($original, $expected) { - global $DB; - - $this->resetAfterTest(); - - $data = new stdClass(); - $data->blockname = 'html'; - $data->parentcontextid = 1; - $data->showinsubcontexts = 0; - $data->requirebytheme = 0; - $data->pagetypepattern = 'admin-setting-frontpagesettings'; - $data->defaultregion = 'side-post'; - $data->defaultweight = 1; - $data->timecreated = time(); - $data->timemodified = time(); - - $data->configdata = $original; - $entryid = $DB->insert_record('block_instances', $data); - upgrade_fix_block_instance_configuration(); - $record = $DB->get_record('block_instances', ['id' => $entryid]); - $this->assertEquals($expected, $record->configdata); - } - /** * Check that orphaned files are deleted. */ From f0d3d5027367a725264fa6dca6c6a3fdfbf5fc50 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 12:06:59 +0100 Subject: [PATCH 08/14] MDL-65809 upgrade: remove upgrade_theme_is_from_family These functions and setting were used only by deleted upgrade steps so it's safe to proceed with straight deletion, considering them internal. Deletion has been documented in corresponding upgrade.txt files: - upgrade_theme_is_from_family() - upgrade_find_theme_location() - linkcoursesectionsupgradescriptwasrun setting --- admin/upgrade.txt | 3 ++ lib/db/upgrade.php | 22 ++++-------- lib/tests/upgradelib_test.php | 38 --------------------- lib/upgradelib.php | 63 ----------------------------------- version.php | 2 +- 5 files changed, 10 insertions(+), 118 deletions(-) diff --git a/admin/upgrade.txt b/admin/upgrade.txt index 9d0e28d89d3..6b11cae79b9 100644 --- a/admin/upgrade.txt +++ b/admin/upgrade.txt @@ -4,6 +4,9 @@ This files describes API changes in /admin/*. * The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info: - upgrade_fix_block_instance_configuration() + - upgrade_theme_is_from_family() + - upgrade_find_theme_location() + - linkcoursesectionsupgradescriptwasrun setting === 3.8 === diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 5b357ff6e19..30d11de6b67 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -922,22 +922,6 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2017082200.01); } - if ($oldversion < 2017082300.01) { - - // This script in included in each major version upgrade process so make sure we don't run it twice. - if (empty($CFG->linkcoursesectionsupgradescriptwasrun)) { - // Check if the site is using a boost-based theme. - // If value of 'linkcoursesections' is set to the old default value, change it to the new default. - if (upgrade_theme_is_from_family('boost', $CFG->theme)) { - set_config('linkcoursesections', 1); - } - set_config('linkcoursesectionsupgradescriptwasrun', 1); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017082300.01); - } - if ($oldversion < 2017082500.00) { // Handle FKs for the table 'analytics_models_log'. $table = new xmldb_table('analytics_models_log'); @@ -3813,5 +3797,11 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2019121800.00); } + if ($oldversion < 2019122000.01) { + // Clean old upgrade setting not used anymore. + unset_config('linkcoursesectionsupgradescriptwasrun'); + upgrade_main_savepoint(true, 2019122000.01); + } + return true; } diff --git a/lib/tests/upgradelib_test.php b/lib/tests/upgradelib_test.php index dde95796083..99b682ba9e8 100644 --- a/lib/tests/upgradelib_test.php +++ b/lib/tests/upgradelib_test.php @@ -783,44 +783,6 @@ class core_upgradelib_testcase extends advanced_testcase { return \org\bovigo\vfs\vfsStream::url('themes'); } - /** - * Test finding theme locations. - */ - public function test_upgrade_find_theme_location() { - global $CFG; - - $this->resetAfterTest(); - - $CFG->themedir = $this->create_testthemes(); - - $this->assertSame($CFG->dirroot . '/theme/boost', upgrade_find_theme_location('boost')); - $this->assertSame($CFG->dirroot . '/theme/classic', upgrade_find_theme_location('classic')); - - $this->assertSame($CFG->themedir . '/testtheme', upgrade_find_theme_location('testtheme')); - $this->assertSame($CFG->themedir . '/childoftesttheme', upgrade_find_theme_location('childoftesttheme')); - } - - /** - * Test figuring out if theme is or is a child of a certain theme. - */ - public function test_upgrade_theme_is_from_family() { - global $CFG; - - $this->resetAfterTest(); - - $CFG->themedir = $this->create_testthemes(); - - $this->assertTrue(upgrade_theme_is_from_family('boost', 'boost'), 'Boost is a boost theme'); - $this->assertTrue(upgrade_theme_is_from_family('boost', 'classic'), 'Classic is a boost base theme'); - $this->assertFalse(upgrade_theme_is_from_family('classic', 'boost'), 'Boost is not a classic theme'); - - $this->assertTrue(upgrade_theme_is_from_family('testtheme', 'childoftesttheme'), 'childoftesttheme is a testtheme'); - $this->assertFalse(upgrade_theme_is_from_family('testtheme', 'orphantheme'), 'ofphantheme is not a testtheme'); - $this->assertTrue(upgrade_theme_is_from_family('testtheme', 'infinite'), 'Infinite loop with testtheme parent is true'); - $this->assertFalse(upgrade_theme_is_from_family('testtheme', 'loop'), 'Infinite loop without testtheme parent is false'); - $this->assertTrue(upgrade_theme_is_from_family('testtheme', 'themewithbrokenparent'), 'No error on broken parent'); - } - /** * Data provider of serialized string. * diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 6cb95b76e5c..66fcf39b8e3 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -2671,66 +2671,3 @@ function upgrade_fix_config_auth_plugin_defaults($plugin) { } } } - -/** - * Search for a given theme in any of the parent themes of a given theme. - * - * @param string $needle The name of the theme you want to search for - * @param string $themename The name of the theme you want to search for - * @param string $checkedthemeforparents The name of all the themes already checked - * @return bool True if found, false if not. - */ -function upgrade_theme_is_from_family($needle, $themename, $checkedthemeforparents = []) { - global $CFG; - - // Once we've started checking a theme, don't start checking it again. Prevent recursion. - if (!empty($checkedthemeforparents[$themename])) { - return false; - } - $checkedthemeforparents[$themename] = true; - - if ($themename == $needle) { - return true; - } - - if ($themedir = upgrade_find_theme_location($themename)) { - $THEME = new stdClass(); - require($themedir . '/config.php'); - $theme = $THEME; - } else { - return false; - } - - if (empty($theme->parents)) { - return false; - } - - // Recursively search through each parent theme. - foreach ($theme->parents as $parent) { - if (upgrade_theme_is_from_family($needle, $parent, $checkedthemeforparents)) { - return true; - } - } - return false; -} - -/** - * Finds the theme location and verifies the theme has all needed files. - * - * @param string $themename The name of the theme you want to search for - * @return string full dir path or null if not found - * @see \theme_config::find_theme_location() - */ -function upgrade_find_theme_location($themename) { - global $CFG; - - if (file_exists("$CFG->dirroot/theme/$themename/config.php")) { - $dir = "$CFG->dirroot/theme/$themename"; - } else if (!empty($CFG->themedir) and file_exists("$CFG->themedir/$themename/config.php")) { - $dir = "$CFG->themedir/$themename"; - } else { - return null; - } - - return $dir; -} diff --git a/version.php b/version.php index 31799972a5b..87422065ce5 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2019122000.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2019122000.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '3.9dev (Build: 20191220)'; // Human-friendly version name From 6f46aa20408f04ab96f4209f7a59feb1fe5bf16b Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 12:11:15 +0100 Subject: [PATCH 09/14] MDL-65809 upgrade: remove upgrade_block_positions This function was used only by deleted upgrade steps so it's safe to proceed with straight deletion, considering it internal. Deletion has been documented in corresponding upgrade.txt files. --- admin/upgrade.txt | 1 + lib/db/upgrade.php | 11 --------- lib/db/upgradelib.php | 15 ------------ lib/tests/upgradelib_test.php | 43 ----------------------------------- 4 files changed, 1 insertion(+), 69 deletions(-) diff --git a/admin/upgrade.txt b/admin/upgrade.txt index 6b11cae79b9..d3adb1808f7 100644 --- a/admin/upgrade.txt +++ b/admin/upgrade.txt @@ -7,6 +7,7 @@ This files describes API changes in /admin/*. - upgrade_theme_is_from_family() - upgrade_find_theme_location() - linkcoursesectionsupgradescriptwasrun setting + - upgrade_block_positions() === 3.8 === diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 30d11de6b67..4f4aeec563f 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -190,17 +190,6 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2017020200.02); } - if ($oldversion < 2017020901.00) { - - // Delete "orphaned" block positions. Note, the query does not use indexes (because there are none), - // if it runs too long during upgrade you can comment this line - it will leave orphaned records - // in the database but they won't bother you. - upgrade_block_positions(); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017020901.00); - } - if ($oldversion < 2017021300.00) { unset_config('loginpasswordautocomplete'); upgrade_main_savepoint(true, 2017021300.00); diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php index 90e6ce06722..d2ebc51d0a7 100644 --- a/lib/db/upgradelib.php +++ b/lib/db/upgradelib.php @@ -488,21 +488,6 @@ function upgrade_standardise_score($rawgrade, $sourcemin, $sourcemax, $targetmin return $standardisedvalue; } -/** - * Delete orphaned records in block_positions - */ -function upgrade_block_positions() { - global $DB; - $id = 'id'; - if ($DB->get_dbfamily() !== 'mysql') { - // Field block_positions.subpage has type 'char', it can not be compared to int in db engines except for mysql. - $id = $DB->sql_concat('?', 'id'); - } - $sql = "DELETE FROM {block_positions} - WHERE pagetype IN ('my-index', 'user-profile') AND subpage NOT IN (SELECT $id FROM {my_pages})"; - $DB->execute($sql, ['']); -} - /** * Provides a way to check and update a serialized string that uses the deprecated object class. * diff --git a/lib/tests/upgradelib_test.php b/lib/tests/upgradelib_test.php index 99b682ba9e8..b68a99280b4 100644 --- a/lib/tests/upgradelib_test.php +++ b/lib/tests/upgradelib_test.php @@ -650,49 +650,6 @@ class core_upgradelib_testcase extends advanced_testcase { } } - /** - * Create two pages with blocks, delete one page and make sure upgrade script deletes orphaned blocks - */ - public function test_delete_block_positions() { - global $DB, $CFG; - require_once($CFG->dirroot . '/my/lib.php'); - $this->resetAfterTest(); - - // Make sure each block on system dashboard page has a position. - $systempage = $DB->get_record('my_pages', array('userid' => null, 'private' => MY_PAGE_PRIVATE)); - $systemcontext = context_system::instance(); - $blockinstances = $DB->get_records('block_instances', array('parentcontextid' => $systemcontext->id, - 'pagetypepattern' => 'my-index', 'subpagepattern' => $systempage->id)); - $this->assertNotEmpty($blockinstances); - foreach ($blockinstances as $bi) { - $DB->insert_record('block_positions', ['subpage' => $systempage->id, 'pagetype' => 'my-index', 'contextid' => $systemcontext->id, - 'blockinstanceid' => $bi->id, 'visible' => 1, 'weight' => $bi->defaultweight]); - } - - // Create two users and make two copies of the system dashboard. - $user1 = $this->getDataGenerator()->create_user(); - $user2 = $this->getDataGenerator()->create_user(); - $page1 = my_copy_page($user1->id, MY_PAGE_PRIVATE, 'my-index'); - $page2 = my_copy_page($user2->id, MY_PAGE_PRIVATE, 'my-index'); - - $context1 = context_user::instance($user1->id); - $context2 = context_user::instance($user2->id); - - // Delete second page without deleting block positions. - $DB->delete_records('my_pages', ['id' => $page2->id]); - - // Blocks are still here. - $this->assertEquals(count($blockinstances), $DB->count_records('block_positions', ['subpage' => $page1->id, 'pagetype' => 'my-index', 'contextid' => $context1->id])); - $this->assertEquals(count($blockinstances), $DB->count_records('block_positions', ['subpage' => $page2->id, 'pagetype' => 'my-index', 'contextid' => $context2->id])); - - // Run upgrade script that should delete orphaned block_positions. - upgrade_block_positions(); - - // First user still has all his block_positions, second user does not. - $this->assertEquals(count($blockinstances), $DB->count_records('block_positions', ['subpage' => $page1->id, 'pagetype' => 'my-index', 'contextid' => $context1->id])); - $this->assertEquals(0, $DB->count_records('block_positions', ['subpage' => $page2->id, 'pagetype' => 'my-index'])); - } - /** * Test the conversion of auth plugin settings names. */ From 089e918033dadf169ade358fad90daf3bb755d66 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 12:40:05 +0100 Subject: [PATCH 10/14] MDL-65809 upgrade: remove upgrade_fix_config_auth_plugin_names These functions were used only by deleted upgrade steps so it's safe to proceed with straight deletion, considering them internal. Deletion has been documented in corresponding upgrade.txt files: - upgrade_fix_config_auth_plugin_names() - upgrade_fix_config_auth_plugin_defaults() --- auth/cas/db/upgrade.php | 7 --- auth/db/db/upgrade.php | 7 --- auth/email/db/upgrade.php | 7 --- auth/ldap/db/upgrade.php | 7 --- auth/manual/db/upgrade.php | 7 --- auth/mnet/db/upgrade.php | 7 --- auth/none/db/upgrade.php | 7 --- auth/shibboleth/db/upgrade.php | 7 --- auth/upgrade.txt | 6 ++ lib/tests/upgradelib_test.php | 51 ----------------- lib/upgradelib.php | 100 --------------------------------- 11 files changed, 6 insertions(+), 207 deletions(-) diff --git a/auth/cas/db/upgrade.php b/auth/cas/db/upgrade.php index c3c413cbc9e..94e043fafc1 100644 --- a/auth/cas/db/upgrade.php +++ b/auth/cas/db/upgrade.php @@ -32,13 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_cas_upgrade($oldversion) { global $CFG; - if ($oldversion < 2017020700) { - // Convert info in config plugins from auth/cas to auth_cas. - upgrade_fix_config_auth_plugin_names('cas'); - upgrade_fix_config_auth_plugin_defaults('cas'); - upgrade_plugin_savepoint(true, 2017020700, 'auth', 'cas'); - } - // Automatically generated Moodle v3.3.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 2a4625c87b2..ff6b84c457b 100644 --- a/auth/db/db/upgrade.php +++ b/auth/db/db/upgrade.php @@ -32,13 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_db_upgrade($oldversion) { global $CFG, $DB; - if ($oldversion < 2017032800) { - // Convert info in config plugins from auth/db to auth_db - upgrade_fix_config_auth_plugin_names('db'); - upgrade_fix_config_auth_plugin_defaults('db'); - upgrade_plugin_savepoint(true, 2017032800, 'auth', 'db'); - } - // Automatically generated Moodle v3.3.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 ac34c970450..5aed8a16eaf 100644 --- a/auth/email/db/upgrade.php +++ b/auth/email/db/upgrade.php @@ -32,13 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_email_upgrade($oldversion) { global $CFG, $DB; - if ($oldversion < 2017020700) { - // Convert info in config plugins from auth/email to auth_email. - upgrade_fix_config_auth_plugin_names('email'); - upgrade_fix_config_auth_plugin_defaults('email'); - upgrade_plugin_savepoint(true, 2017020700, 'auth', 'email'); - } - // Automatically generated Moodle v3.3.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 d99fdccc464..76de06c914d 100644 --- a/auth/ldap/db/upgrade.php +++ b/auth/ldap/db/upgrade.php @@ -32,13 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_ldap_upgrade($oldversion) { global $CFG; - if ($oldversion < 2017020700) { - // Convert info in config plugins from auth/ldap to auth_ldap. - upgrade_fix_config_auth_plugin_names('ldap'); - upgrade_fix_config_auth_plugin_defaults('ldap'); - upgrade_plugin_savepoint(true, 2017020700, 'auth', 'ldap'); - } - // Automatically generated Moodle v3.3.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 8afe128b488..0835379883b 100644 --- a/auth/manual/db/upgrade.php +++ b/auth/manual/db/upgrade.php @@ -32,13 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_manual_upgrade($oldversion) { global $CFG; - if ($oldversion < 2017020700) { - // Convert info in config plugins from auth/manual to auth_manual. - upgrade_fix_config_auth_plugin_names('manual'); - upgrade_fix_config_auth_plugin_defaults('manual'); - upgrade_plugin_savepoint(true, 2017020700, 'auth', 'manual'); - } - // Automatically generated Moodle v3.3.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 905920d33b8..54b9ea01f90 100644 --- a/auth/mnet/db/upgrade.php +++ b/auth/mnet/db/upgrade.php @@ -32,13 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_mnet_upgrade($oldversion) { global $CFG; - if ($oldversion < 2017020700) { - // Convert info in config plugins from auth/mnet to auth_mnet. - upgrade_fix_config_auth_plugin_names('mnet'); - upgrade_fix_config_auth_plugin_defaults('mnet'); - upgrade_plugin_savepoint(true, 2017020700, 'auth', 'mnet'); - } - // Automatically generated Moodle v3.3.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 7619cf662a2..a2fd45bfbc2 100644 --- a/auth/none/db/upgrade.php +++ b/auth/none/db/upgrade.php @@ -32,13 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_none_upgrade($oldversion) { global $CFG, $DB; - if ($oldversion < 2017020700) { - // Convert info in config plugins from auth/none to auth_none. - upgrade_fix_config_auth_plugin_names('none'); - upgrade_fix_config_auth_plugin_defaults('none'); - upgrade_plugin_savepoint(true, 2017020700, 'auth', 'none'); - } - // Automatically generated Moodle v3.3.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 c57f98d0dd2..4532bc193ec 100644 --- a/auth/shibboleth/db/upgrade.php +++ b/auth/shibboleth/db/upgrade.php @@ -32,13 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_shibboleth_upgrade($oldversion) { global $CFG, $DB; - if ($oldversion < 2017020700) { - // Convert info in config plugins from auth/shibboleth to auth_shibboleth. - upgrade_fix_config_auth_plugin_names('shibboleth'); - upgrade_fix_config_auth_plugin_defaults('shibboleth'); - upgrade_plugin_savepoint(true, 2017020700, 'auth', 'shibboleth'); - } - // Automatically generated Moodle v3.3.0 release upgrade line. // Put any upgrade step following this. diff --git a/auth/upgrade.txt b/auth/upgrade.txt index 917165985d3..79a3b80d4be 100644 --- a/auth/upgrade.txt +++ b/auth/upgrade.txt @@ -1,6 +1,12 @@ This files describes API changes in /auth/* - plugins, information provided here is intended especially for developers. +=== 3.9 === + +* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info: + - upgrade_fix_config_auth_plugin_names() + - upgrade_fix_config_auth_plugin_defaults() + === 3.7 === * get_password_change_info() method is added to the base class and returns an array containing the subject and body of the message diff --git a/lib/tests/upgradelib_test.php b/lib/tests/upgradelib_test.php index b68a99280b4..b4cd3fd9d86 100644 --- a/lib/tests/upgradelib_test.php +++ b/lib/tests/upgradelib_test.php @@ -650,57 +650,6 @@ class core_upgradelib_testcase extends advanced_testcase { } } - /** - * Test the conversion of auth plugin settings names. - */ - public function test_upgrade_fix_config_auth_plugin_names() { - $this->resetAfterTest(); - - // Let the plugin auth_foo use legacy format only. - set_config('name1', 'val1', 'auth/foo'); - set_config('name2', 'val2', 'auth/foo'); - - // Let the plugin auth_bar use new format only. - set_config('name1', 'val1', 'auth_bar'); - set_config('name2', 'val2', 'auth_bar'); - - // Let the plugin auth_baz use a mix of legacy and new format, with no conflicts. - set_config('name1', 'val1', 'auth_baz'); - set_config('name1', 'val1', 'auth/baz'); - set_config('name2', 'val2', 'auth/baz'); - set_config('name3', 'val3', 'auth_baz'); - - // Let the plugin auth_qux use a mix of legacy and new format, with conflicts. - set_config('name1', 'val1', 'auth_qux'); - set_config('name1', 'val2', 'auth/qux'); - - // Execute the migration. - upgrade_fix_config_auth_plugin_names('foo'); - upgrade_fix_config_auth_plugin_names('bar'); - upgrade_fix_config_auth_plugin_names('baz'); - upgrade_fix_config_auth_plugin_names('qux'); - - // Assert that legacy settings are gone and no new were introduced. - $this->assertEmpty((array) get_config('auth/foo')); - $this->assertEmpty((array) get_config('auth/bar')); - $this->assertEmpty((array) get_config('auth/baz')); - $this->assertEmpty((array) get_config('auth/qux')); - - // Assert values were simply kept where there was no conflict. - $this->assertSame('val1', get_config('auth_foo', 'name1')); - $this->assertSame('val2', get_config('auth_foo', 'name2')); - - $this->assertSame('val1', get_config('auth_bar', 'name1')); - $this->assertSame('val2', get_config('auth_bar', 'name2')); - - $this->assertSame('val1', get_config('auth_baz', 'name1')); - $this->assertSame('val2', get_config('auth_baz', 'name2')); - $this->assertSame('val3', get_config('auth_baz', 'name3')); - - // Assert the new format took precedence in case of conflict. - $this->assertSame('val1', get_config('auth_qux', 'name1')); - } - /** * Create a collection of test themes to test determining parent themes. * diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 66fcf39b8e3..ee2e4daa71e 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -2571,103 +2571,3 @@ function check_libcurl_version(environment_results $result) { return null; } - -/** - * Fix how auth plugins are called in the 'config_plugins' table. - * - * For legacy reasons, the auth plugins did not always use their frankenstyle - * component name in the 'plugin' column of the 'config_plugins' table. This is - * a helper function to correctly migrate the legacy settings into the expected - * and consistent way. - * - * @param string $plugin the auth plugin name such as 'cas', 'manual' or 'mnet' - */ -function upgrade_fix_config_auth_plugin_names($plugin) { - global $CFG, $DB, $OUTPUT; - - $legacy = (array) get_config('auth/'.$plugin); - $current = (array) get_config('auth_'.$plugin); - - // I don't want to rely on array_merge() and friends here just in case - // there was some crazy setting with a numerical name. - - if ($legacy) { - $new = $legacy; - } else { - $new = []; - } - - if ($current) { - foreach ($current as $name => $value) { - if (isset($legacy[$name]) && ($legacy[$name] !== $value)) { - // No need to pollute the output during unit tests. - if (!empty($CFG->upgraderunning)) { - $message = get_string('settingmigrationmismatch', 'core_auth', [ - 'plugin' => 'auth_'.$plugin, - 'setting' => s($name), - 'legacy' => s($legacy[$name]), - 'current' => s($value), - ]); - echo $OUTPUT->notification($message, \core\output\notification::NOTIFY_ERROR); - - upgrade_log(UPGRADE_LOG_NOTICE, 'auth_'.$plugin, 'Setting values mismatch detected', - 'SETTING: '.$name. ' LEGACY: '.$legacy[$name].' CURRENT: '.$value); - } - } - - $new[$name] = $value; - } - } - - foreach ($new as $name => $value) { - set_config($name, $value, 'auth_'.$plugin); - unset_config($name, 'auth/'.$plugin); - } -} - -/** - * Populate the auth plugin settings with defaults if needed. - * - * As a result of fixing the auth plugins config storage, many settings would - * be falsely reported as new ones by admin/upgradesettings.php. We do not want - * to confuse admins so we try to reduce the bewilderment by pre-populating the - * config_plugins table with default values. This should be done only for - * disabled auth methods. The enabled methods have their settings already - * stored, so reporting actual new settings for them is valid. - * - * @param string $plugin the auth plugin name such as 'cas', 'manual' or 'mnet' - */ -function upgrade_fix_config_auth_plugin_defaults($plugin) { - global $CFG; - - $pluginman = core_plugin_manager::instance(); - $enabled = $pluginman->get_enabled_plugins('auth'); - - if (isset($enabled[$plugin])) { - // Do not touch settings of enabled auth methods. - return; - } - - // We can't directly use {@link core\plugininfo\auth::load_settings()} here - // because the plugins are not fully upgraded yet. Instead, we emulate what - // that method does. We fetch a temporary instance of the plugin's settings - // page to get access to the settings and their defaults. Note we are not - // adding that temporary instance into the admin tree. Yes, this is a hack. - - $plugininfo = $pluginman->get_plugin_info('auth_'.$plugin); - $adminroot = admin_get_root(); - $ADMIN = $adminroot; - $auth = $plugininfo; - - $section = $plugininfo->get_settings_section_name(); - $settingspath = $plugininfo->full_path('settings.php'); - - if (file_exists($settingspath)) { - $settings = new admin_settingpage($section, 'Emulated settings page for auth_'.$plugin, 'moodle/site:config'); - include($settingspath); - - if ($settings) { - admin_apply_default_settings($settings, false); - } - } -} From 3f224a1a4115665ac5a1fc469a7ac03422ed287c Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 12:54:53 +0100 Subject: [PATCH 11/14] MDL-65809 upgrade: remove format_xxx_upgrade_remove_numsections These functions were used only by deleted upgrade steps so it's safe to proceed with straight deletion, considering them internal. Deletion has been documented in corresponding upgrade.txt files: - format_topics_upgrade_remove_numsections() - format_topics_upgrade_hide_extra_sections() - format_topics_upgrade_add_empty_sections() - format_weeks_upgrade_remove_numsections() - format_weeks_upgrade_hide_extra_sections() - format_weeks_upgrade_add_empty_sections() --- course/format/topics/db/upgrade.php | 10 -- course/format/topics/db/upgradelib.php | 144 ----------------- .../tests/format_topics_upgrade_test.php | 153 ------------------ course/format/upgrade.txt | 10 ++ course/format/weeks/db/upgrade.php | 9 -- course/format/weeks/db/upgradelib.php | 144 ----------------- .../weeks/tests/format_weeks_upgrade_test.php | 153 ------------------ 7 files changed, 10 insertions(+), 613 deletions(-) delete mode 100644 course/format/topics/db/upgradelib.php delete mode 100644 course/format/topics/tests/format_topics_upgrade_test.php delete mode 100644 course/format/weeks/db/upgradelib.php delete mode 100644 course/format/weeks/tests/format_weeks_upgrade_test.php diff --git a/course/format/topics/db/upgrade.php b/course/format/topics/db/upgrade.php index 1882296069c..9f2c42551de 100644 --- a/course/format/topics/db/upgrade.php +++ b/course/format/topics/db/upgrade.php @@ -33,16 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_format_topics_upgrade($oldversion) { global $CFG, $DB; - require_once($CFG->dirroot . '/course/format/topics/db/upgradelib.php'); - - if ($oldversion < 2017020200) { - - // Remove 'numsections' option and hide or delete orphaned sections. - format_topics_upgrade_remove_numsections(); - - upgrade_plugin_savepoint(true, 2017020200, 'format', 'topics'); - } - // Automatically generated Moodle v3.3.0 release upgrade line. // Put any upgrade step following this. diff --git a/course/format/topics/db/upgradelib.php b/course/format/topics/db/upgradelib.php deleted file mode 100644 index e231cbcd2a0..00000000000 --- a/course/format/topics/db/upgradelib.php +++ /dev/null @@ -1,144 +0,0 @@ -. - -/** - * Upgrade scripts for course format "Topics" - * - * @package format_topics - * @copyright 2017 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -/** - * This method finds all courses in 'topics' format that have actual number of sections - * different than their 'numsections' course format option. - * - * For courses where there are more sections than numsections, we call - * {@link format_topics_upgrade_hide_extra_sections()} and - * either delete or hide "orphaned" sections. For courses where there are fewer sections - * than numsections, we call {@link format_topics_upgrade_add_empty_sections()} to add - * these sections. - */ -function format_topics_upgrade_remove_numsections() { - global $DB; - - $sql1 = "SELECT c.id, max(cs.section) AS sectionsactual - FROM {course} c - JOIN {course_sections} cs ON cs.course = c.id - WHERE c.format = :format1 - GROUP BY c.id"; - - $sql2 = "SELECT c.id, n.value AS numsections - FROM {course} c - JOIN {course_format_options} n ON n.courseid = c.id AND n.format = :format1 AND n.name = :numsections AND n.sectionid = 0 - WHERE c.format = :format2"; - - $params = ['format1' => 'topics', 'format2' => 'topics', 'numsections' => 'numsections']; - - $actual = $DB->get_records_sql_menu($sql1, $params); - $numsections = $DB->get_records_sql_menu($sql2, $params); - $needfixing = []; - $needsections = []; - - $defaultnumsections = get_config('moodlecourse', 'numsections'); - - foreach ($actual as $courseid => $sectionsactual) { - if (array_key_exists($courseid, $numsections)) { - $n = (int)$numsections[$courseid]; - } else { - $n = $defaultnumsections; - } - if ($sectionsactual > $n) { - $needfixing[$courseid] = $n; - } else if ($sectionsactual < $n) { - $needsections[$courseid] = $n; - } - } - unset($actual); - unset($numsections); - - foreach ($needfixing as $courseid => $numsections) { - format_topics_upgrade_hide_extra_sections($courseid, $numsections); - } - - foreach ($needsections as $courseid => $numsections) { - format_topics_upgrade_add_empty_sections($courseid, $numsections); - } - - $DB->delete_records('course_format_options', ['format' => 'topics', 'sectionid' => 0, 'name' => 'numsections']); -} - -/** - * Find all sections in the course with sectionnum bigger than numsections. - * Either delete these sections or hide them - * - * We will only delete a section if it is completely empty and all sections below - * it are also empty - * - * @param int $courseid - * @param int $numsections - */ -function format_topics_upgrade_hide_extra_sections($courseid, $numsections) { - global $DB; - $sections = $DB->get_records_sql('SELECT id, name, summary, sequence, visible - FROM {course_sections} - WHERE course = ? AND section > ? - ORDER BY section DESC', [$courseid, $numsections]); - $candelete = true; - $tohide = []; - $todelete = []; - foreach ($sections as $section) { - if ($candelete && (!empty($section->summary) || !empty($section->sequence) || !empty($section->name))) { - $candelete = false; - } - if ($candelete) { - $todelete[] = $section->id; - } else if ($section->visible) { - $tohide[] = $section->id; - } - } - if ($todelete) { - // Delete empty sections in the end. - // This is an upgrade script - no events or cache resets are needed. - // We also know that these sections do not have any modules so it is safe to just delete records in the table. - $DB->delete_records_list('course_sections', 'id', $todelete); - } - if ($tohide) { - // Hide other orphaned sections. - // This is different from what set_section_visible() does but we want to preserve actual - // module visibility in this case. - list($sql, $params) = $DB->get_in_or_equal($tohide); - $DB->execute("UPDATE {course_sections} SET visible = 0 WHERE id " . $sql, $params); - } -} - -/** - * This method adds empty sections to courses which have fewer sections than their - * 'numsections' course format option and adds these empty sections. - * - * @param int $courseid - * @param int $numsections - */ -function format_topics_upgrade_add_empty_sections($courseid, $numsections) { - global $DB; - $existingsections = $DB->get_fieldset_sql('SELECT section from {course_sections} WHERE course = ?', [$courseid]); - $newsections = array_diff(range(0, $numsections), $existingsections); - foreach ($newsections as $sectionnum) { - course_create_section($courseid, $sectionnum, true); - } -} diff --git a/course/format/topics/tests/format_topics_upgrade_test.php b/course/format/topics/tests/format_topics_upgrade_test.php deleted file mode 100644 index 690c71589ea..00000000000 --- a/course/format/topics/tests/format_topics_upgrade_test.php +++ /dev/null @@ -1,153 +0,0 @@ -. - -/** - * format_topics unit tests for upgradelib - * - * @package format_topics - * @copyright 2015 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -global $CFG; -require_once($CFG->dirroot . '/course/lib.php'); -require_once($CFG->dirroot . '/course/format/topics/db/upgradelib.php'); - -/** - * format_topics unit tests for upgradelib - * - * @package format_topics - * @copyright 2017 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class format_topics_upgrade_testcase extends advanced_testcase { - - /** - * Test upgrade step to remove orphaned sections. - */ - public function test_numsections_no_actions() { - global $DB; - - $this->resetAfterTest(true); - - $params = array('format' => 'topics', 'numsections' => 5, 'startdate' => 1445644800); - $course = $this->getDataGenerator()->create_course($params); - // This test is executed after 'numsections' option was already removed, add it manually. - $DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'topics', - 'sectionid' => 0, 'name' => 'numsections', 'value' => '5']); - - // There are 6 sections in the course (0-section and sections 1, ... 5). - $this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id])); - - format_topics_upgrade_remove_numsections(); - - // There are still 6 sections in the course. - $this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id])); - - } - - /** - * Test upgrade step to remove orphaned sections. - */ - public function test_numsections_delete_empty() { - global $DB; - - $this->resetAfterTest(true); - - // Set default number of sections to 10. - set_config('numsections', 10, 'moodlecourse'); - - $params1 = array('format' => 'topics', 'numsections' => 5, 'startdate' => 1445644800); - $course1 = $this->getDataGenerator()->create_course($params1); - $params2 = array('format' => 'topics', 'numsections' => 20, 'startdate' => 1445644800); - $course2 = $this->getDataGenerator()->create_course($params2); - // This test is executed after 'numsections' option was already removed, add it manually and - // set it to be 2 less than actual number of sections. - $DB->insert_record('course_format_options', ['courseid' => $course1->id, 'format' => 'topics', - 'sectionid' => 0, 'name' => 'numsections', 'value' => '3']); - - // There are 6 sections in the first course (0-section and sections 1, ... 5). - $this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course1->id])); - // There are 21 sections in the second course. - $this->assertEquals(21, $DB->count_records('course_sections', ['course' => $course2->id])); - - format_topics_upgrade_remove_numsections(); - - // Two sections were deleted in the first course. - $this->assertEquals(4, $DB->count_records('course_sections', ['course' => $course1->id])); - // The second course was reset to 11 sections (default plus 0-section). - $this->assertEquals(11, $DB->count_records('course_sections', ['course' => $course2->id])); - - } - - /** - * Test upgrade step to remove orphaned sections. - */ - public function test_numsections_hide_non_empty() { - global $DB; - - $this->resetAfterTest(true); - - $params = array('format' => 'topics', 'numsections' => 5, 'startdate' => 1445644800); - $course = $this->getDataGenerator()->create_course($params); - - // Add a module to the second last section. - $cm = $this->getDataGenerator()->create_module('forum', ['course' => $course->id, 'section' => 4]); - - // This test is executed after 'numsections' option was already removed, add it manually and - // set it to be 2 less than actual number of sections. - $DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'topics', - 'sectionid' => 0, 'name' => 'numsections', 'value' => '3']); - - // There are 6 sections. - $this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id])); - - format_topics_upgrade_remove_numsections(); - - // One section was deleted and one hidden. - $this->assertEquals(5, $DB->count_records('course_sections', ['course' => $course->id])); - $this->assertEquals(0, $DB->get_field('course_sections', 'visible', ['course' => $course->id, 'section' => 4])); - // The module is still visible. - $this->assertEquals(1, $DB->get_field('course_modules', 'visible', ['id' => $cm->cmid])); - } - - /** - * Test upgrade step to add empty sections. - */ - public function test_numsections_add_empty_sections() { - global $DB; - - $this->resetAfterTest(true); - - $params = array('format' => 'topics', 'numsections' => 16, 'startdate' => 1445644800); - $course = $this->getDataGenerator()->create_course($params); - - // This test is executed after 'numsections' option was already removed. - // Set the 'numsections' course format value to 18, simulating the scenario in which there are fewer real sections. - $DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'topics', - 'sectionid' => 0, 'name' => 'numsections', 'value' => '18']); - - // There are 16 sections. - $this->assertEquals(17, $DB->count_records('course_sections', ['course' => $course->id])); - - format_topics_upgrade_remove_numsections(); - - // Confirm that the upgrade method added the missing empty sections. - $this->assertEquals(19, $DB->count_records('course_sections', ['course' => $course->id])); - } -} diff --git a/course/format/upgrade.txt b/course/format/upgrade.txt index d549e468742..bac0e59b9c2 100644 --- a/course/format/upgrade.txt +++ b/course/format/upgrade.txt @@ -2,6 +2,16 @@ This files describes API changes for course formats Overview of this plugin type at http://docs.moodle.org/dev/Course_formats +=== 3.9 === + +* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info: + - format_topics_upgrade_remove_numsections() + - format_topics_upgrade_hide_extra_sections() + - format_topics_upgrade_add_empty_sections() + - format_weeks_upgrade_remove_numsections() + - format_weeks_upgrade_hide_extra_sections() + - format_weeks_upgrade_add_empty_sections() + === 3.8 === * The following functions have been finally deprecated and can not be used anymore: diff --git a/course/format/weeks/db/upgrade.php b/course/format/weeks/db/upgrade.php index 7f81260c84e..ac4123f2792 100644 --- a/course/format/weeks/db/upgrade.php +++ b/course/format/weeks/db/upgrade.php @@ -34,15 +34,6 @@ function xmldb_format_weeks_upgrade($oldversion) { global $CFG, $DB; require_once($CFG->dirroot . '/course/format/weeks/lib.php'); - require_once($CFG->dirroot . '/course/format/weeks/db/upgradelib.php'); - - if ($oldversion < 2017020200) { - - // Remove 'numsections' option and hide or delete orphaned sections. - format_weeks_upgrade_remove_numsections(); - - upgrade_plugin_savepoint(true, 2017020200, 'format', 'weeks'); - } if ($oldversion < 2017050300) { // Go through the existing courses using the weeks format with no value set for the 'automaticenddate'. diff --git a/course/format/weeks/db/upgradelib.php b/course/format/weeks/db/upgradelib.php deleted file mode 100644 index 2c5a5b1225f..00000000000 --- a/course/format/weeks/db/upgradelib.php +++ /dev/null @@ -1,144 +0,0 @@ -. - -/** - * Upgrade scripts for course format "Weeks" - * - * @package format_weeks - * @copyright 2017 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -/** - * This method finds all courses in 'topics' format that have actual number of sections - * different than their 'numsections' course format option. - * - * For courses where there are more sections than numsections, we call - * {@link format_weeks_upgrade_hide_extra_sections()} and - * either delete or hide "orphaned" sections. For courses where there are fewer sections - * than numsections, we call {@link format_weeks_upgrade_add_empty_sections()} to add - * these sections. - */ -function format_weeks_upgrade_remove_numsections() { - global $DB; - - $sql1 = "SELECT c.id, max(cs.section) AS sectionsactual - FROM {course} c - JOIN {course_sections} cs ON cs.course = c.id - WHERE c.format = :format1 - GROUP BY c.id"; - - $sql2 = "SELECT c.id, n.value AS numsections - FROM {course} c - JOIN {course_format_options} n ON n.courseid = c.id AND n.format = :format1 AND n.name = :numsections AND n.sectionid = 0 - WHERE c.format = :format2"; - - $params = ['format1' => 'weeks', 'format2' => 'weeks', 'numsections' => 'numsections']; - - $actual = $DB->get_records_sql_menu($sql1, $params); - $numsections = $DB->get_records_sql_menu($sql2, $params); - $needfixing = []; - $needsections = []; - - $defaultnumsections = get_config('moodlecourse', 'numsections'); - - foreach ($actual as $courseid => $sectionsactual) { - if (array_key_exists($courseid, $numsections)) { - $n = (int)$numsections[$courseid]; - } else { - $n = $defaultnumsections; - } - if ($sectionsactual > $n) { - $needfixing[$courseid] = $n; - } else if ($sectionsactual < $n) { - $needsections[$courseid] = $n; - } - } - unset($actual); - unset($numsections); - - foreach ($needfixing as $courseid => $numsections) { - format_weeks_upgrade_hide_extra_sections($courseid, $numsections); - } - - foreach ($needsections as $courseid => $numsections) { - format_weeks_upgrade_add_empty_sections($courseid, $numsections); - } - - $DB->delete_records('course_format_options', ['format' => 'weeks', 'sectionid' => 0, 'name' => 'numsections']); -} - -/** - * Find all sections in the course with sectionnum bigger than numsections. - * Either delete these sections or hide them - * - * We will only delete a section if it is completely empty and all sections below - * it are also empty - * - * @param int $courseid - * @param int $numsections - */ -function format_weeks_upgrade_hide_extra_sections($courseid, $numsections) { - global $DB; - $sections = $DB->get_records_sql('SELECT id, name, summary, sequence, visible - FROM {course_sections} - WHERE course = ? AND section > ? - ORDER BY section DESC', [$courseid, $numsections]); - $candelete = true; - $tohide = []; - $todelete = []; - foreach ($sections as $section) { - if ($candelete && (!empty($section->summary) || !empty($section->sequence) || !empty($section->name))) { - $candelete = false; - } - if ($candelete) { - $todelete[] = $section->id; - } else if ($section->visible) { - $tohide[] = $section->id; - } - } - if ($todelete) { - // Delete empty sections in the end. - // This is an upgrade script - no events or cache resets are needed. - // We also know that these sections do not have any modules so it is safe to just delete records in the table. - $DB->delete_records_list('course_sections', 'id', $todelete); - } - if ($tohide) { - // Hide other orphaned sections. - // This is different from what set_section_visible() does but we want to preserve actual - // module visibility in this case. - list($sql, $params) = $DB->get_in_or_equal($tohide); - $DB->execute("UPDATE {course_sections} SET visible = 0 WHERE id " . $sql, $params); - } -} - -/** - * This method adds empty sections to courses which have fewer sections than their - * 'numsections' course format option and adds these empty sections. - * - * @param int $courseid - * @param int $numsections - */ -function format_weeks_upgrade_add_empty_sections($courseid, $numsections) { - global $DB; - $existingsections = $DB->get_fieldset_sql('SELECT section from {course_sections} WHERE course = ?', [$courseid]); - $newsections = array_diff(range(0, $numsections), $existingsections); - foreach ($newsections as $sectionnum) { - course_create_section($courseid, $sectionnum, true); - } -} diff --git a/course/format/weeks/tests/format_weeks_upgrade_test.php b/course/format/weeks/tests/format_weeks_upgrade_test.php deleted file mode 100644 index 3cc8f153009..00000000000 --- a/course/format/weeks/tests/format_weeks_upgrade_test.php +++ /dev/null @@ -1,153 +0,0 @@ -. - -/** - * format_weeks unit tests for upgradelib - * - * @package format_weeks - * @copyright 2015 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -global $CFG; -require_once($CFG->dirroot . '/course/lib.php'); -require_once($CFG->dirroot . '/course/format/weeks/db/upgradelib.php'); - -/** - * format_weeks unit tests for upgradelib - * - * @package format_weeks - * @copyright 2017 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class format_weeks_upgrade_testcase extends advanced_testcase { - - /** - * Test upgrade step to remove orphaned sections. - */ - public function test_numsections_no_actions() { - global $DB; - - $this->resetAfterTest(true); - - $params = array('format' => 'weeks', 'numsections' => 5, 'startdate' => 1445644800); - $course = $this->getDataGenerator()->create_course($params); - // This test is executed after 'numsections' option was already removed, add it manually. - $DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'weeks', - 'sectionid' => 0, 'name' => 'numsections', 'value' => '5']); - - // There are 6 sections in the course (0-section and sections 1, ... 5). - $this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id])); - - format_weeks_upgrade_remove_numsections(); - - // There are still 6 sections in the course. - $this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id])); - - } - - /** - * Test upgrade step to remove orphaned sections. - */ - public function test_numsections_delete_empty() { - global $DB; - - $this->resetAfterTest(true); - - // Set default number of sections to 10. - set_config('numsections', 10, 'moodlecourse'); - - $params1 = array('format' => 'weeks', 'numsections' => 5, 'startdate' => 1445644800); - $course1 = $this->getDataGenerator()->create_course($params1); - $params2 = array('format' => 'weeks', 'numsections' => 20, 'startdate' => 1445644800); - $course2 = $this->getDataGenerator()->create_course($params2); - // This test is executed after 'numsections' option was already removed, add it manually and - // set it to be 2 less than actual number of sections. - $DB->insert_record('course_format_options', ['courseid' => $course1->id, 'format' => 'weeks', - 'sectionid' => 0, 'name' => 'numsections', 'value' => '3']); - - // There are 6 sections in the first course (0-section and sections 1, ... 5). - $this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course1->id])); - // There are 21 sections in the second course. - $this->assertEquals(21, $DB->count_records('course_sections', ['course' => $course2->id])); - - format_weeks_upgrade_remove_numsections(); - - // Two sections were deleted in the first course. - $this->assertEquals(4, $DB->count_records('course_sections', ['course' => $course1->id])); - // The second course was reset to 11 sections (default plus 0-section). - $this->assertEquals(11, $DB->count_records('course_sections', ['course' => $course2->id])); - - } - - /** - * Test upgrade step to remove orphaned sections. - */ - public function test_numsections_hide_non_empty() { - global $DB; - - $this->resetAfterTest(true); - - $params = array('format' => 'weeks', 'numsections' => 5, 'startdate' => 1445644800); - $course = $this->getDataGenerator()->create_course($params); - - // Add a module to the second last section. - $cm = $this->getDataGenerator()->create_module('forum', ['course' => $course->id, 'section' => 4]); - - // This test is executed after 'numsections' option was already removed, add it manually and - // set it to be 2 less than actual number of sections. - $DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'weeks', - 'sectionid' => 0, 'name' => 'numsections', 'value' => '3']); - - // There are 6 sections. - $this->assertEquals(6, $DB->count_records('course_sections', ['course' => $course->id])); - - format_weeks_upgrade_remove_numsections(); - - // One section was deleted and one hidden. - $this->assertEquals(5, $DB->count_records('course_sections', ['course' => $course->id])); - $this->assertEquals(0, $DB->get_field('course_sections', 'visible', ['course' => $course->id, 'section' => 4])); - // The module is still visible. - $this->assertEquals(1, $DB->get_field('course_modules', 'visible', ['id' => $cm->cmid])); - } - - /** - * Test upgrade step to add empty sections. - */ - public function test_numsections_add_empty_sections() { - global $DB; - - $this->resetAfterTest(true); - - $params = array('format' => 'weeks', 'numsections' => 16, 'startdate' => 1445644800); - $course = $this->getDataGenerator()->create_course($params); - - // This test is executed after 'numsections' option was already removed. - // Set the 'numsections' course format value to 18, simulating the scenario in which there are fewer real sections. - $DB->insert_record('course_format_options', ['courseid' => $course->id, 'format' => 'weeks', - 'sectionid' => 0, 'name' => 'numsections', 'value' => '18']); - - // There are 16 sections. - $this->assertEquals(17, $DB->count_records('course_sections', ['course' => $course->id])); - - format_weeks_upgrade_remove_numsections(); - - // Confirm that the upgrade method added the missing empty sections. - $this->assertEquals(19, $DB->count_records('course_sections', ['course' => $course->id])); - } -} From 08bc1f11dbff82b1078ecbb30693564980c6280a Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 13:12:51 +0100 Subject: [PATCH 12/14] MDL-65809 upgrade: remove filter_mathjaxloader_upgrade_xxx These functions were used only by deleted upgrade steps so it's safe to proceed with straight deletion, considering them internal. Deletion has been documented in corresponding upgrade.txt files: - filter_mathjaxloader_upgrade_cdn_cloudflare() - filter_mathjaxloader_upgrade_mathjaxconfig_equal() --- filter/mathjaxloader/db/upgrade.php | 123 ----------------- filter/mathjaxloader/db/upgradelib.php | 95 -------------- .../mathjaxloader/tests/upgradelib_test.php | 124 ------------------ filter/upgrade.txt | 6 + 4 files changed, 6 insertions(+), 342 deletions(-) delete mode 100644 filter/mathjaxloader/db/upgradelib.php delete mode 100644 filter/mathjaxloader/tests/upgradelib_test.php diff --git a/filter/mathjaxloader/db/upgrade.php b/filter/mathjaxloader/db/upgrade.php index c01643f2a54..9b64471bc64 100644 --- a/filter/mathjaxloader/db/upgrade.php +++ b/filter/mathjaxloader/db/upgrade.php @@ -31,129 +31,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_filter_mathjaxloader_upgrade($oldversion) { global $CFG; - require_once($CFG->dirroot . '/filter/mathjaxloader/db/upgradelib.php'); - - if ($oldversion < 2017040300) { - - $httpsurl = get_config('filter_mathjaxloader', 'httpsurl'); - $newcdnurl = filter_mathjaxloader_upgrade_cdn_cloudflare($httpsurl, false); - - set_config('httpsurl', $newcdnurl, 'filter_mathjaxloader'); - - $mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig'); - if (strpos($mathjaxconfig, 'MathJax.Ajax.config.path') === false) { - $newconfig = 'MathJax.Ajax.config.path["Contrib"] = "{wwwroot}/filter/mathjaxloader/contrib";' . "\n"; - $newconfig .= $mathjaxconfig; - - set_config('mathjaxconfig', $newconfig, 'filter_mathjaxloader'); - } - - upgrade_plugin_savepoint(true, 2017040300, 'filter', 'mathjaxloader'); - } - - if ($oldversion < 2017042602) { - - $httpsurl = get_config('filter_mathjaxloader', 'httpsurl'); - if ($httpsurl === "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js") { - set_config('httpsurl', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js', 'filter_mathjaxloader'); - } - - $mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig'); - - if (strpos($mathjaxconfig, 'MathJax.Ajax.config.path') !== false) { - // Now we need to remove this config again because mathjax 2.7.1 supports the extensions on the CDN. - $configtoremove = 'MathJax.Ajax.config.path["Contrib"] = "{wwwroot}/filter/mathjaxloader/contrib";'; - - $mathjaxconfig = str_replace($configtoremove, '', $mathjaxconfig); - - set_config('mathjaxconfig', $mathjaxconfig, 'filter_mathjaxloader'); - } - - upgrade_plugin_savepoint(true, 2017042602, 'filter', 'mathjaxloader'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017091900) { - - $httpsurl = get_config('filter_mathjaxloader', 'httpsurl'); - if (empty($httpsurl)) { - // URL is empty, most likely because of bad upgrade path. See MDL-59780. - set_config('httpsurl', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js', 'filter_mathjaxloader'); - } - upgrade_plugin_savepoint(true, 2017091900, 'filter', 'mathjaxloader'); - } - - if ($oldversion < 2017100900) { - // Update the MathJax CDN URL to the new default if the site has been using default value. - $httpsurl = get_config('filter_mathjaxloader', 'httpsurl'); - if ($httpsurl === 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js') { - set_config('httpsurl', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js', 'filter_mathjaxloader'); - } - upgrade_plugin_savepoint(true, 2017100900, 'filter', 'mathjaxloader'); - } - - if ($oldversion < 2017101200) { - // Update default MathJax configuration so that it does not use the Accessible.js config (causes JS errors due to upstream bug). - $previousdefault = ' -MathJax.Hub.Config({ - config: ["Accessible.js", "Safe.js"], - errorSettings: { message: ["!"] }, - skipStartupTypeset: true, - messageStyle: "none" -}); -'; - - $newdefault = ' -MathJax.Hub.Config({ - config: ["default.js", "MMLorHTML.js", "Safe.js"], - errorSettings: { message: ["!"] }, - skipStartupTypeset: true, - messageStyle: "none" -}); -'; - - $mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig'); - - if (empty($mathjaxconfig) || filter_mathjaxloader_upgrade_mathjaxconfig_equal($mathjaxconfig, $previousdefault)) { - set_config('mathjaxconfig', $newdefault, 'filter_mathjaxloader'); - } - - upgrade_plugin_savepoint(true, 2017101200, 'filter', 'mathjaxloader'); - } - - if ($oldversion < 2017102000) { - // Re-add Accessible.js (we should not have removed it). - $previousdefault = ' -MathJax.Hub.Config({ - config: ["default.js", "MMLorHTML.js", "Safe.js"], - errorSettings: { message: ["!"] }, - skipStartupTypeset: true, - messageStyle: "none" -}); -'; - $newdefault = ' -MathJax.Hub.Config({ - config: ["Accessible.js", "Safe.js"], - errorSettings: { message: ["!"] }, - skipStartupTypeset: true, - messageStyle: "none" -}); -'; - - $mathjaxconfig = get_config('filter_mathjaxloader', 'mathjaxconfig'); - - if (empty($mathjaxconfig) || filter_mathjaxloader_upgrade_mathjaxconfig_equal($mathjaxconfig, $previousdefault)) { - set_config('mathjaxconfig', $newdefault, 'filter_mathjaxloader'); - } - - upgrade_plugin_savepoint(true, 2017102000, 'filter', 'mathjaxloader'); - } - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/filter/mathjaxloader/db/upgradelib.php b/filter/mathjaxloader/db/upgradelib.php deleted file mode 100644 index 813075698a8..00000000000 --- a/filter/mathjaxloader/db/upgradelib.php +++ /dev/null @@ -1,95 +0,0 @@ -. - -/** - * Random functions for mathjax upgrades. - * - * @package filter_mathjaxloader - * @copyright 2017 Damyon Wiese (damyon@moodle.com) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -/** - * This function takes an existing mathjax url and, if it was using the standard mathjax cdn, - * upgrades it to use the cloudflare matchjax cdn (because the standard one is shutting down). - * @param string $mathjaxurl - The current url. - * @param boolean $httponly - Use http instead of https - really only for 3.1 upgrades. - * @return string The new url. - */ -function filter_mathjaxloader_upgrade_cdn_cloudflare($mathjaxurl, $httponly = false) { - $newcdnurl = $mathjaxurl; - $cdnroot = 'https://cdn.mathjax.org/mathjax/'; - if ($httponly) { - $cdnroot = 'http://cdn.mathjax.org/mathjax/'; - } - $usingcdn = strpos($mathjaxurl, $cdnroot) === 0; - if ($usingcdn) { - $majorversion = substr($mathjaxurl, strlen($cdnroot), 3); - $latestversion = '2.7.0'; - if ($majorversion == '2.6') { - $latestversion = '2.6.1'; - } else if ($majorversion == '2.5') { - $latestversion = '2.5.3'; - } - - $offset = strpos($mathjaxurl, '/', strlen($cdnroot)); - if ($offset === false) { - return $newcdnurl; - } - - $endofurl = substr($mathjaxurl, $offset + 1); - - $newcdnbase = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/'; - if ($httponly) { - $newcdnbase = 'http://cdnjs.cloudflare.com/ajax/libs/mathjax/'; - } - - $newcdnurl = $newcdnbase . $latestversion . '/' . $endofurl; - } - - return $newcdnurl; -} - -/** - * Compares two values of the 'mathjaxconfig' config option. - * - * This is used during the upgrade to see if the two text values of the 'mathjaxconfig' config option should be - * considered equal of different. The strings are normalized so that EOL characters and whitespace is not significant. - * - * @param string $val1 value - * @param string $val2 value - * @return bool true if the texts should be considered equals, false otherwise - */ -function filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2) { - - $val1lines = preg_split("/[\r\n]/", $val1); - $val2lines = preg_split("/[\r\n]/", $val2); - - $val1lines = array_map('trim', $val1lines); - $val2lines = array_map('trim', $val2lines); - - $val1lines = array_filter($val1lines, function($value) { - return $value !== ''; - }); - - $val2lines = array_filter($val2lines, function($value) { - return $value !== ''; - }); - - return (implode(' ', $val1lines) === implode(' ', $val2lines)); -} diff --git a/filter/mathjaxloader/tests/upgradelib_test.php b/filter/mathjaxloader/tests/upgradelib_test.php deleted file mode 100644 index 092f293b858..00000000000 --- a/filter/mathjaxloader/tests/upgradelib_test.php +++ /dev/null @@ -1,124 +0,0 @@ -. - -/** - * Unit test for the upgrade MathJax code. - * - * @package filter_mathjaxloader - * @copyright 2017 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -global $CFG; -require_once($CFG->dirroot . '/filter/mathjaxloader/db/upgradelib.php'); - -/** - * Unit test for the upgrade MathJax code. - * - * Test the functions in upgradelib.php - * - * @copyright 2017 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class filter_mathjax_upgradelib_testcase extends advanced_testcase { - - /** - * Tests for {@link filter_mathjaxloader_upgrade_cdn_cloudflare()} function. - */ - public function test_filter_mathjaxloader_upgrade_cdn_cloudflare() { - $current = 'https://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...'; - $expected = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?...'; - $this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current)); - - $current = 'http://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...'; - $expected = 'http://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?...'; - $this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current, true)); - - $current = 'http://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...'; - $expected = 'http://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...'; - $this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current, false)); - - $current = 'https://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...'; - $expected = 'https://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js?...'; - $this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current, true)); - - $current = 'https://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?...'; - $expected = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.6.1/MathJax.js?...'; - $this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current)); - - $current = 'https://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js?...'; - $expected = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.5.3/MathJax.js?...'; - $this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current)); - - // Dont touch non https links. - $current = 'http://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js?...'; - $expected = 'http://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js?...'; - $this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current)); - - // Dont touch non local links. - $current = 'https://mylocalmirror/mathjax/2.7-latest/MathJax.js?...'; - $expected = 'https://mylocalmirror/mathjax/2.7-latest/MathJax.js?...'; - $this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current)); - - // Try some unexpected things. - $current = ''; - $expected = ''; - $this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current)); - - // Try some unexpected things. - $current = 'https://cdn.mathjax.org/mathjax/2.7-latest/MathJax.js'; - $expected = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js'; - $this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current)); - - // Try some unexpected things. - $current = 'https://cdn.mathjax.org/mathjax/2.7-latest'; - $expected = 'https://cdn.mathjax.org/mathjax/2.7-latest'; - $this->assertEquals($expected, filter_mathjaxloader_upgrade_cdn_cloudflare($current)); - } - - /** - * Tests for {@link filter_mathjaxloader_upgrade_mathjaxconfig_equal()} function. - */ - public function test_filter_mathjaxloader_upgrade_mathjaxconfig_equal() { - - $val1 = ''; - $val2 = "\n \r \r\n \t "; - $this->assertTrue(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2)); - - $val1 = '0'; - $val2 = ''; - $this->assertFalse(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2)); - - $val1 = 'Hello Unittest, my old friend '.PHP_EOL."I've come to play with you again \r\n\r\n \t "; - $val2 = ' Hello Unittest, my old friend '."\r\n\r\n"." I've come to play with you again \n\n\n "; - $this->assertTrue(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2)); - - $val1 = "\n".'MathJax.Hub.Config({'."\n".' config: ["Accessible.js", "Safe.js"]'."\n".'});'."\n"; - $val2 = 'MathJax.Hub.Config({'."\r".'config: ["Accessible.js", "Safe.js"]'."\r".'});'; - $this->assertTrue(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2)); - - $val1 = "\r\n\t".'MathJax.Hub.Config({'."\r\n\t".' config: ["Accessible.js", "Safe.js"]'."\r\n".'}); '."\r\n\r\n"; - $val2 = 'MathJax.Hub.Config({'."\n".'config: ["Accessible.js", "Safe.js"]'."\r".'});'; - $this->assertTrue(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2)); - - $val2 = 'MathJax.Hub.Config({'."\n".'config: ["Significant.js"]'."\n".'});'; - $val2 = 'MathJax.Hub.Config({'."\n".'config: ["Signi ficant.js", "Safe.js"]'."\n".'});'; - $this->assertFalse(filter_mathjaxloader_upgrade_mathjaxconfig_equal($val1, $val2)); - } -} - diff --git a/filter/upgrade.txt b/filter/upgrade.txt index 3ccfc6e333f..dfccf3f5f4e 100644 --- a/filter/upgrade.txt +++ b/filter/upgrade.txt @@ -1,6 +1,12 @@ This file describes API changes in core filter API and plugins, information provided here is intended especially for developers. +=== 3.9 === + +* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info: + - filter_mathjaxloader_upgrade_cdn_cloudflare() + - filter_mathjaxloader_upgrade_mathjaxconfig_equal() + === 3.6 === * Although there is no API change that require you to update your filter, From d2b7f6f556d0024b359fdbe92b3eb0a89d20d81e Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 13:22:10 +0100 Subject: [PATCH 13/14] MDL-65809 upgrade: remove get_assignments_with_rescaled_null_grades This function was used only by deleted upgrade steps so it's safe to proceed with straight deletion, considering it internal. Deletion has been documented in corresponding upgrade.txt files. --- mod/assign/db/upgrade.php | 102 ----------------------------- mod/assign/tests/locallib_test.php | 65 ------------------ mod/assign/upgrade.txt | 6 ++ mod/assign/upgradelib.php | 24 ------- 4 files changed, 6 insertions(+), 191 deletions(-) diff --git a/mod/assign/db/upgrade.php b/mod/assign/db/upgrade.php index 598abdb4100..50854793b72 100644 --- a/mod/assign/db/upgrade.php +++ b/mod/assign/db/upgrade.php @@ -34,108 +34,6 @@ function xmldb_assign_upgrade($oldversion) { $dbman = $DB->get_manager(); - if ($oldversion < 2017021500) { - // Fix event types of assign events. - $params = [ - 'modulename' => 'assign', - 'eventtype' => 'close' - ]; - $select = "modulename = :modulename AND eventtype = :eventtype"; - $DB->set_field_select('event', 'eventtype', 'due', $select, $params); - - // Delete 'open' events. - $params = [ - 'modulename' => 'assign', - 'eventtype' => 'open' - ]; - $DB->delete_records('event', $params); - - // Assign savepoint reached. - upgrade_mod_savepoint(true, 2017021500, 'assign'); - } - - if ($oldversion < 2017031300) { - // Add a 'gradingduedate' field to the 'assign' table. - $table = new xmldb_table('assign'); - $field = new xmldb_field('gradingduedate', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0, 'cutoffdate'); - - // Conditionally launch add field. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Assign savepoint reached. - upgrade_mod_savepoint(true, 2017031300, 'assign'); - } - - if ($oldversion < 2017042800) { - // Update query to set the grading due date one week after the due date. - // Only assign instances with grading due date not set and with a due date of not older than 3 weeks will be updated. - $sql = "UPDATE {assign} - SET gradingduedate = duedate + :weeksecs - WHERE gradingduedate = 0 - AND duedate > :timelimit"; - - // Calculate the time limit, which is 3 weeks before the current date. - $interval = new DateInterval('P3W'); - $timelimit = new DateTime(); - $timelimit->sub($interval); - - // Update query params. - $params = [ - 'weeksecs' => WEEKSECS, - 'timelimit' => $timelimit->getTimestamp() - ]; - - // Execute DB update for assign instances. - $DB->execute($sql, $params); - - // Assign savepoint reached. - upgrade_mod_savepoint(true, 2017042800, 'assign'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017061200) { - // Data fix any assign group override event priorities which may have been accidentally nulled due to a bug on the group - // overrides edit form. - - // First, find all assign group override events having null priority (and join their corresponding assign_overrides entry). - $sql = "SELECT e.id AS id, o.sortorder AS priority - FROM {assign_overrides} o - JOIN {event} e ON (e.modulename = 'assign' AND o.assignid = e.instance AND e.groupid = o.groupid) - WHERE o.groupid IS NOT NULL AND e.priority IS NULL - ORDER BY o.id"; - $affectedrs = $DB->get_recordset_sql($sql); - - // Now update the event's priority based on the assign_overrides sortorder we found. This uses similar logic to - // assign_refresh_events(), except we've restricted the set of assignments and overrides we're dealing with here. - foreach ($affectedrs as $record) { - $DB->set_field('event', 'priority', $record->priority, ['id' => $record->id]); - } - $affectedrs->close(); - - // Main savepoint reached. - upgrade_mod_savepoint(true, 2017061200, 'assign'); - } - - if ($oldversion < 2017061205) { - require_once($CFG->dirroot.'/mod/assign/upgradelib.php'); - $brokenassigns = get_assignments_with_rescaled_null_grades(); - - // Set config value. - foreach ($brokenassigns as $assign) { - set_config('has_rescaled_null_grades_' . $assign, 1, 'assign'); - } - - // Main savepoint reached. - upgrade_mod_savepoint(true, 2017061205, 'assign'); - } - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/mod/assign/tests/locallib_test.php b/mod/assign/tests/locallib_test.php index 51f464e21d9..33d9751207b 100644 --- a/mod/assign/tests/locallib_test.php +++ b/mod/assign/tests/locallib_test.php @@ -3785,71 +3785,6 @@ Anchor link 2:Link text $this->assertEquals(1, $completiondata->completionstate); } - public function get_assignments_with_rescaled_null_grades_provider() { - return [ - 'Negative less than one is errant' => [ - 'grade' => -0.64, - 'count' => 1, - ], - 'Negative more than one is errant' => [ - 'grade' => -30.18, - 'count' => 1, - ], - 'Negative one exactly is not errant' => [ - 'grade' => ASSIGN_GRADE_NOT_SET, - 'count' => 0, - ], - 'Positive grade is not errant' => [ - 'grade' => 1, - 'count' => 0, - ], - 'Large grade is not errant' => [ - 'grade' => 100, - 'count' => 0, - ], - 'Zero grade is not errant' => [ - 'grade' => 0, - 'count' => 0, - ], - ]; - } - - /** - * Test determining if the assignment as any null grades that were rescaled. - * @dataProvider get_assignments_with_rescaled_null_grades_provider - */ - public function test_get_assignments_with_rescaled_null_grades($grade, $count) { - global $DB; - - $this->resetAfterTest(); - - $course = $this->getDataGenerator()->create_course(); - $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher'); - $student = $this->getDataGenerator()->create_and_enrol($course, 'student'); - - $this->setUser($teacher); - $assign = $this->create_instance($course, [ - 'grade' => 100, - ]); - - // Try getting a student's grade. This will give a grade of -1. - // Then we can override it with a bad negative grade. - $assign->get_user_grade($student->id, true); - - // Set the grade to something errant. - $DB->set_field( - 'assign_grades', - 'grade', - $grade, - [ - 'userid' => $student->id, - 'assignment' => $assign->get_instance()->id, - ] - ); - - $this->assertCount($count, get_assignments_with_rescaled_null_grades()); - } - /** * Data provider for test_fix_null_grades * @return array[] Test data for test_fix_null_grades. Each element should contain grade, expectedcount and gradebookvalue diff --git a/mod/assign/upgrade.txt b/mod/assign/upgrade.txt index e68d31c5ce3..017ba655cb8 100644 --- a/mod/assign/upgrade.txt +++ b/mod/assign/upgrade.txt @@ -1,4 +1,10 @@ This files describes API changes in the assign code. + +=== 3.9 === + +* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info: + - get_assignments_with_rescaled_null_grades() + === 3.8 === * The allow_image_conversion method has been added to the submissionplugins. It determines whether the submission plugin allows image conversion or not. By default conversion is not allowed (except when overwritten in the submission plugin) diff --git a/mod/assign/upgradelib.php b/mod/assign/upgradelib.php index 10ab600920a..c4fff773043 100644 --- a/mod/assign/upgradelib.php +++ b/mod/assign/upgradelib.php @@ -414,27 +414,3 @@ class assign_upgrade_manager { return $newcm; } } - -/** - * Determines if the assignment as any null grades that were rescaled. - * - * Null grades are stored as -1 but should never be rescaled. - * - * @return int[] Array of the ids of all the assignments with rescaled null grades. - */ -function get_assignments_with_rescaled_null_grades() { - global $DB; - - $query = 'SELECT id, assignment FROM {assign_grades} - WHERE grade < 0 AND grade <> -1'; - - $assignments = array_values($DB->get_records_sql($query)); - - $getassignmentid = function ($assignment) { - return $assignment->assignment; - }; - - $assignments = array_map($getassignmentid, $assignments); - - return $assignments; -} From a26cfe71d3c1dcfad350814d714be0447d5393cc Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 5 Dec 2019 13:40:24 +0100 Subject: [PATCH 14/14] MDL-65809 upgrade: clean < 3.5.0 upgrade steps This just deletes all the upgrade steps previous to 3.5.0. Some small adjustments, like tweaking globals can also be applied when needed. Also includes an upgrade step to prevent upgrading from any version < 2018051700 (v3.5.0) as anti-cheating measure. Previous commits have removed/deprecated all the upgradelib functions not used anymore in codebase. Deletion has been documented in corresponding upgrade.txt files: - upgrade_fix_block_instance_configuration() - upgrade_theme_is_from_family(), upgrade_find_theme_location() and linkcoursesectionsupgradescriptwasrun setting - upgrade_block_positions - upgrade_fix_config_auth_plugin_names() and upgrade_fix_config_auth_plugin_defaults() - format_xxx_upgrade_remove_numsections(), format_xxx_upgrade_hide_extra_sections() and format_xxx_upgrade_add_empty_sections() - filter_mathjaxloader_upgrade_cdn_cloudflare() and filter_mathjaxloader_upgrade_mathjaxconfig_equal() - get_assignments_with_rescaled_null_grades() These have been kept because continue being used by restore: - \core\task\refresh_mod_calendar_events_task --- admin/tool/customlang/db/upgrade.php | 6 - admin/tool/log/db/upgrade.php | 6 - admin/tool/log/store/database/db/upgrade.php | 6 - admin/tool/log/store/standard/db/upgrade.php | 6 - admin/tool/monitor/db/upgrade.php | 23 - admin/tool/usertours/db/upgrade.php | 6 - auth/cas/db/upgrade.php | 6 - auth/db/db/upgrade.php | 6 - auth/email/db/upgrade.php | 6 - auth/ldap/db/upgrade.php | 24 - auth/manual/db/upgrade.php | 6 - auth/mnet/db/upgrade.php | 6 - auth/none/db/upgrade.php | 6 - auth/oauth2/db/upgrade.php | 6 - auth/shibboleth/db/upgrade.php | 6 - blocks/badges/db/upgrade.php | 6 - blocks/calendar_month/db/upgrade.php | 6 - blocks/calendar_upcoming/db/upgrade.php | 6 - blocks/completionstatus/db/upgrade.php | 6 - blocks/course_summary/db/upgrade.php | 6 - blocks/html/db/upgrade.php | 6 - blocks/navigation/db/upgrade.php | 6 - blocks/quiz_results/db/upgrade.php | 6 - blocks/recent_activity/db/upgrade.php | 6 - blocks/rss_client/db/upgrade.php | 6 - blocks/section_links/db/upgrade.php | 6 - blocks/selfcompletion/db/upgrade.php | 6 - blocks/settings/db/upgrade.php | 6 - course/format/topics/db/upgrade.php | 16 - course/format/weeks/db/upgrade.php | 53 - enrol/database/db/upgrade.php | 6 - enrol/flatfile/db/upgrade.php | 6 - enrol/guest/db/upgrade.php | 6 - enrol/imsenterprise/db/upgrade.php | 6 - enrol/lti/db/upgrade.php | 23 +- enrol/manual/db/upgrade.php | 6 - enrol/mnet/db/upgrade.php | 6 - enrol/paypal/db/upgrade.php | 6 - enrol/self/db/upgrade.php | 6 - filter/mediaplugin/db/upgrade.php | 6 - filter/tex/db/upgrade.php | 6 - grade/grading/form/guide/db/upgrade.php | 6 - grade/grading/form/rubric/db/upgrade.php | 6 - grade/report/overview/db/upgrade.php | 16 - grade/report/user/db/upgrade.php | 6 - lib/antivirus/clamav/db/upgrade.php | 6 - lib/db/upgrade.php | 1655 +---------------- lib/editor/atto/db/upgrade.php | 62 - .../atto/plugins/equation/db/upgrade.php | 6 - lib/editor/tinymce/db/upgrade.php | 6 - .../plugins/spellchecker/db/upgrade.php | 6 - message/output/email/db/upgrade.php | 6 - message/output/jabber/db/upgrade.php | 6 - message/output/popup/db/upgrade.php | 46 +- mod/assign/feedback/comments/db/upgrade.php | 6 - mod/assign/feedback/editpdf/db/upgrade.php | 22 - mod/assign/feedback/file/db/upgrade.php | 6 - mod/assign/submission/comments/db/upgrade.php | 6 - mod/assign/submission/file/db/upgrade.php | 6 - .../submission/onlinetext/db/upgrade.php | 6 - mod/assignment/db/upgrade.php | 6 - mod/book/db/upgrade.php | 6 - mod/chat/db/upgrade.php | 37 +- mod/choice/db/upgrade.php | 6 - mod/data/db/upgrade.php | 23 - mod/feedback/db/upgrade.php | 38 +- mod/folder/db/upgrade.php | 10 +- mod/forum/db/upgrade.php | 51 - mod/glossary/db/upgrade.php | 8 +- mod/imscp/db/upgrade.php | 6 - mod/label/db/upgrade.php | 19 +- mod/lesson/db/upgrade.php | 61 +- mod/lti/db/upgrade.php | 58 - mod/page/db/upgrade.php | 6 - mod/quiz/db/upgrade.php | 119 +- mod/quiz/report/overview/db/upgrade.php | 6 - mod/quiz/report/statistics/db/upgrade.php | 6 - mod/resource/db/upgrade.php | 6 - mod/scorm/db/upgrade.php | 28 +- mod/survey/db/upgrade.php | 6 - mod/url/db/upgrade.php | 6 - mod/wiki/db/upgrade.php | 6 - mod/workshop/db/upgrade.php | 25 +- mod/workshop/form/accumulative/db/upgrade.php | 6 - mod/workshop/form/comments/db/upgrade.php | 6 - mod/workshop/form/numerrors/db/upgrade.php | 6 - mod/workshop/form/rubric/db/upgrade.php | 6 - portfolio/boxnet/db/upgrade.php | 6 - portfolio/googledocs/db/upgrade.php | 6 - portfolio/picasa/db/upgrade.php | 6 - .../behaviour/manualgraded/db/upgrade.php | 6 - question/type/calculated/db/upgrade.php | 6 - question/type/ddmarker/db/upgrade.php | 6 - question/type/essay/db/upgrade.php | 25 +- question/type/match/db/upgrade.php | 6 - question/type/multianswer/db/upgrade.php | 6 - question/type/multichoice/db/upgrade.php | 6 - question/type/numerical/db/upgrade.php | 22 +- question/type/random/db/upgrade.php | 6 - question/type/randomsamatch/db/upgrade.php | 6 - question/type/shortanswer/db/upgrade.php | 6 - repository/boxnet/db/upgrade.php | 6 - repository/dropbox/db/upgrade.php | 6 - repository/flickr/db/upgrade.php | 15 +- repository/googledocs/db/upgrade.php | 38 - repository/onedrive/db/upgrade.php | 10 +- repository/picasa/db/upgrade.php | 6 - 107 files changed, 19 insertions(+), 2988 deletions(-) diff --git a/admin/tool/customlang/db/upgrade.php b/admin/tool/customlang/db/upgrade.php index 561a56a1414..cf935d8d96a 100644 --- a/admin/tool/customlang/db/upgrade.php +++ b/admin/tool/customlang/db/upgrade.php @@ -29,12 +29,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_tool_customlang_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/admin/tool/log/db/upgrade.php b/admin/tool/log/db/upgrade.php index c62e8de5a7d..3a8e7977a4c 100644 --- a/admin/tool/log/db/upgrade.php +++ b/admin/tool/log/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_tool_log_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 b68d31e352b..ec36ccf8d63 100644 --- a/admin/tool/log/store/database/db/upgrade.php +++ b/admin/tool/log/store/database/db/upgrade.php @@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_logstore_database_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 63a312feb23..5a9a7e01ea8 100644 --- a/admin/tool/log/store/standard/db/upgrade.php +++ b/admin/tool/log/store/standard/db/upgrade.php @@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_logstore_standard_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 2e746d5353d..b8c93ac95f7 100644 --- a/admin/tool/monitor/db/upgrade.php +++ b/admin/tool/monitor/db/upgrade.php @@ -33,29 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_tool_monitor_upgrade($oldversion) { global $CFG, $DB; - if ($oldversion < 2017021300) { - - // Delete "orphaned" subscriptions. - $sql = "SELECT DISTINCT s.courseid - FROM {tool_monitor_subscriptions} s - LEFT OUTER JOIN {course} c ON c.id = s.courseid - WHERE s.courseid <> 0 and c.id IS NULL"; - $deletedcourses = $DB->get_field_sql($sql); - if ($deletedcourses) { - list($sql, $params) = $DB->get_in_or_equal($deletedcourses); - $DB->execute("DELETE FROM {tool_monitor_subscriptions} WHERE courseid " . $sql, $params); - } - - // Monitor savepoint reached. - upgrade_plugin_savepoint(true, 2017021300, 'tool', 'monitor'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 7a6019499fd..a6855ea908c 100644 --- a/admin/tool/usertours/db/upgrade.php +++ b/admin/tool/usertours/db/upgrade.php @@ -35,12 +35,6 @@ use tool_usertours\manager; function xmldb_tool_usertours_upgrade($oldversion) { global $CFG, $DB; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 94e043fafc1..8b2d14b38c0 100644 --- a/auth/cas/db/upgrade.php +++ b/auth/cas/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_cas_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 ff6b84c457b..3a0691c9707 100644 --- a/auth/db/db/upgrade.php +++ b/auth/db/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_db_upgrade($oldversion) { global $CFG, $DB; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 5aed8a16eaf..3d2b42d10c9 100644 --- a/auth/email/db/upgrade.php +++ b/auth/email/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_email_upgrade($oldversion) { global $CFG, $DB; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 76de06c914d..abb56a9b303 100644 --- a/auth/ldap/db/upgrade.php +++ b/auth/ldap/db/upgrade.php @@ -32,30 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_ldap_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017080100) { - // The "auth_ldap/coursecreators" setting was replaced with "auth_ldap/coursecreatorcontext" (created - // dynamically from system-assignable roles) - so migrate any existing value to the first new slot. - if ($ldapcontext = get_config('auth_ldap', 'creators')) { - // Get info about the role that the old coursecreators setting would apply. - $creatorrole = get_archetype_roles('coursecreator'); - $creatorrole = array_shift($creatorrole); // We can only use one, let's use the first. - - // Create new setting. - set_config($creatorrole->shortname . 'context', $ldapcontext, 'auth_ldap'); - - // Delete old setting. - set_config('creators', null, 'auth_ldap'); - - upgrade_plugin_savepoint(true, 2017080100, 'auth', 'ldap'); - } - } - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 0835379883b..0795fc25159 100644 --- a/auth/manual/db/upgrade.php +++ b/auth/manual/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_manual_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 54b9ea01f90..fcb489d5a0a 100644 --- a/auth/mnet/db/upgrade.php +++ b/auth/mnet/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_mnet_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 a2fd45bfbc2..ebf92f3878a 100644 --- a/auth/none/db/upgrade.php +++ b/auth/none/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_none_upgrade($oldversion) { global $CFG, $DB; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 6dac6f2c653..8e8fc1a5495 100644 --- a/auth/oauth2/db/upgrade.php +++ b/auth/oauth2/db/upgrade.php @@ -35,12 +35,6 @@ function xmldb_auth_oauth2_upgrade($oldversion) { $dbman = $DB->get_manager(); - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 4532bc193ec..54d240e57c8 100644 --- a/auth/shibboleth/db/upgrade.php +++ b/auth/shibboleth/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_auth_shibboleth_upgrade($oldversion) { global $CFG, $DB; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 afaa541ce74..c7ae4518ab4 100644 --- a/blocks/badges/db/upgrade.php +++ b/blocks/badges/db/upgrade.php @@ -45,12 +45,6 @@ function xmldb_block_badges_upgrade($oldversion, $block) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 fee24ff3234..b97b4ffa1fc 100644 --- a/blocks/calendar_month/db/upgrade.php +++ b/blocks/calendar_month/db/upgrade.php @@ -45,12 +45,6 @@ function xmldb_block_calendar_month_upgrade($oldversion, $block) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 4134778f20e..f99b9ea4787 100644 --- a/blocks/calendar_upcoming/db/upgrade.php +++ b/blocks/calendar_upcoming/db/upgrade.php @@ -45,12 +45,6 @@ function xmldb_block_calendar_upcoming_upgrade($oldversion, $block) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 3535e7e1d77..b30d8f236a6 100644 --- a/blocks/completionstatus/db/upgrade.php +++ b/blocks/completionstatus/db/upgrade.php @@ -48,12 +48,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_block_completionstatus_upgrade($oldversion, $block) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 6f3406ebb2e..18a78cfb794 100644 --- a/blocks/course_summary/db/upgrade.php +++ b/blocks/course_summary/db/upgrade.php @@ -48,12 +48,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_block_course_summary_upgrade($oldversion, $block) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 56f328fadd3..52176dffa70 100644 --- a/blocks/html/db/upgrade.php +++ b/blocks/html/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_block_html_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 ecf4b3d843b..c8ca634091a 100644 --- a/blocks/navigation/db/upgrade.php +++ b/blocks/navigation/db/upgrade.php @@ -55,12 +55,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_block_navigation_upgrade($oldversion, $block) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/blocks/quiz_results/db/upgrade.php b/blocks/quiz_results/db/upgrade.php index a110739d0b5..7b7aab02493 100644 --- a/blocks/quiz_results/db/upgrade.php +++ b/blocks/quiz_results/db/upgrade.php @@ -45,12 +45,6 @@ function xmldb_block_quiz_results_upgrade($oldversion, $block) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 d4c5f04eab3..84dfeab163e 100644 --- a/blocks/recent_activity/db/upgrade.php +++ b/blocks/recent_activity/db/upgrade.php @@ -47,12 +47,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_block_recent_activity_upgrade($oldversion, $block) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 33798132834..844c8c6ab50 100644 --- a/blocks/rss_client/db/upgrade.php +++ b/blocks/rss_client/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_block_rss_client_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 558a8cc3d80..d14edc24961 100644 --- a/blocks/section_links/db/upgrade.php +++ b/blocks/section_links/db/upgrade.php @@ -49,12 +49,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_block_section_links_upgrade($oldversion, $block) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 2e776a688af..ad3b5397e58 100644 --- a/blocks/selfcompletion/db/upgrade.php +++ b/blocks/selfcompletion/db/upgrade.php @@ -48,12 +48,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_block_selfcompletion_upgrade($oldversion, $block) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 0eb69d55d77..afe0e14d027 100644 --- a/blocks/settings/db/upgrade.php +++ b/blocks/settings/db/upgrade.php @@ -55,12 +55,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_block_settings_upgrade($oldversion, $block) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 9f2c42551de..d455f9f664d 100644 --- a/course/format/topics/db/upgrade.php +++ b/course/format/topics/db/upgrade.php @@ -33,22 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_format_topics_upgrade($oldversion) { global $CFG, $DB; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2018030900) { - - // During upgrade to Moodle 3.3 it could happen that general section (section 0) became 'invisible'. - // It should always be visible. - $DB->execute("UPDATE {course_sections} SET visible=1 WHERE visible=0 AND section=0 AND course IN - (SELECT id FROM {course} WHERE format=?)", ['topics']); - - upgrade_plugin_savepoint(true, 2018030900, 'format', 'topics'); - } - // Automatically generated Moodle v3.5.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 ac4123f2792..a7d1c9dc89d 100644 --- a/course/format/weeks/db/upgrade.php +++ b/course/format/weeks/db/upgrade.php @@ -33,59 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_format_weeks_upgrade($oldversion) { global $CFG, $DB; - require_once($CFG->dirroot . '/course/format/weeks/lib.php'); - - if ($oldversion < 2017050300) { - // Go through the existing courses using the weeks format with no value set for the 'automaticenddate'. - $sql = "SELECT c.id, c.enddate, cfo.id as cfoid - FROM {course} c - LEFT JOIN {course_format_options} cfo - ON cfo.courseid = c.id - AND cfo.format = c.format - AND cfo.name = :optionname - AND cfo.sectionid = 0 - WHERE c.format = :format - AND cfo.id IS NULL"; - $params = ['optionname' => 'automaticenddate', 'format' => 'weeks']; - $courses = $DB->get_recordset_sql($sql, $params); - foreach ($courses as $course) { - $option = new stdClass(); - $option->courseid = $course->id; - $option->format = 'weeks'; - $option->sectionid = 0; - $option->name = 'automaticenddate'; - if (empty($course->enddate)) { - $option->value = 1; - $DB->insert_record('course_format_options', $option); - - // Now, let's update the course end date. - format_weeks::update_end_date($course->id); - } else { - $option->value = 0; - $DB->insert_record('course_format_options', $option); - } - } - $courses->close(); - - upgrade_plugin_savepoint(true, 2017050300, 'format', 'weeks'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2018030900) { - - // During upgrade to Moodle 3.3 it could happen that general section (section 0) became 'invisible'. - // It should always be visible. - $DB->execute("UPDATE {course_sections} SET visible=1 WHERE visible=0 AND section=0 AND course IN - (SELECT id FROM {course} WHERE format=?)", ['weeks']); - - upgrade_plugin_savepoint(true, 2018030900, 'format', 'weeks'); - } - // Automatically generated Moodle v3.5.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 f6ccd935d93..b492dfacfd5 100644 --- a/enrol/database/db/upgrade.php +++ b/enrol/database/db/upgrade.php @@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_enrol_database_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 be60e579d9a..7ba1a90cba7 100644 --- a/enrol/flatfile/db/upgrade.php +++ b/enrol/flatfile/db/upgrade.php @@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_enrol_flatfile_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 2faa9cea2be..0ac5154983e 100644 --- a/enrol/guest/db/upgrade.php +++ b/enrol/guest/db/upgrade.php @@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_enrol_guest_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 44ccd212cd8..b1e9e98387a 100644 --- a/enrol/imsenterprise/db/upgrade.php +++ b/enrol/imsenterprise/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_enrol_imsenterprise_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 b99ed66749c..d8e0e5d3016 100644 --- a/enrol/lti/db/upgrade.php +++ b/enrol/lti/db/upgrade.php @@ -37,28 +37,7 @@ * @return boolean */ function xmldb_enrol_lti_upgrade($oldversion) { - global $DB; - - $dbman = $DB->get_manager(); - - if ($oldversion < 2017011300) { - - // Changing precision of field value on table enrol_lti_lti2_nonce to (64). - $table = new xmldb_table('enrol_lti_lti2_nonce'); - $field = new xmldb_field('value', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null, 'consumerid'); - - // Launch change of precision for field value. - $dbman->change_field_precision($table, $field); - - // Lti savepoint reached. - upgrade_plugin_savepoint(true, 2017011300, 'enrol', 'lti'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. + global $CFG; // Automatically generated Moodle v3.5.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 08ca26a9ef9..d709a5cf2e1 100644 --- a/enrol/manual/db/upgrade.php +++ b/enrol/manual/db/upgrade.php @@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_enrol_manual_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 06c098ca1d2..005dab97de4 100644 --- a/enrol/mnet/db/upgrade.php +++ b/enrol/mnet/db/upgrade.php @@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_enrol_mnet_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 fe4370f6d42..8cc31b0d9ac 100644 --- a/enrol/paypal/db/upgrade.php +++ b/enrol/paypal/db/upgrade.php @@ -47,12 +47,6 @@ function xmldb_enrol_paypal_upgrade($oldversion) { $dbman = $DB->get_manager(); - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 f065fbf2593..20b46ddf4d3 100644 --- a/enrol/self/db/upgrade.php +++ b/enrol/self/db/upgrade.php @@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_enrol_self_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 431749f8701..9f1b26b20ba 100644 --- a/filter/mediaplugin/db/upgrade.php +++ b/filter/mediaplugin/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_filter_mediaplugin_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 e08f0819d5d..9e1a27fff41 100644 --- a/filter/tex/db/upgrade.php +++ b/filter/tex/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_filter_tex_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 213bad808b0..66340e8cfcf 100644 --- a/grade/grading/form/guide/db/upgrade.php +++ b/grade/grading/form/guide/db/upgrade.php @@ -37,12 +37,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_gradingform_guide_upgrade($oldversion) { global $DB; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 c23b0d0a8ec..af2611e824f 100644 --- a/grade/grading/form/rubric/db/upgrade.php +++ b/grade/grading/form/rubric/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_gradingform_rubric_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 57b559c536d..c94287c24fe 100644 --- a/grade/report/overview/db/upgrade.php +++ b/grade/report/overview/db/upgrade.php @@ -32,22 +32,6 @@ defined('MOODLE_INTERNAL') || die(); */ function xmldb_gradereport_overview_upgrade($oldversion) { - if ($oldversion < 2017051501) { - $context = context_system::instance(); - $capability = 'gradereport/overview:view'; - - // Now allow authenticated user role to access that report. - $authenticateduserroles = get_archetype_roles('user'); - foreach ($authenticateduserroles as $roleid => $notused) { - assign_capability($capability, CAP_ALLOW, $roleid, $context->id); - } - - upgrade_plugin_savepoint(true, 2017051501, 'gradereport', 'overview'); - } - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 3fcbd5389b6..679129fe7d3 100644 --- a/grade/report/user/db/upgrade.php +++ b/grade/report/user/db/upgrade.php @@ -29,12 +29,6 @@ function xmldb_gradereport_user_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 71d1f11c3af..8477172e649 100644 --- a/lib/antivirus/clamav/db/upgrade.php +++ b/lib/antivirus/clamav/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); */ function xmldb_antivirus_clamav_upgrade($oldversion) { - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 4f4aeec563f..4c56b3969c5 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -92,1660 +92,13 @@ function xmldb_main_upgrade($oldversion) { $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.2.0 right now). - if ($oldversion < 2016120500) { + // allowed version to upgrade from (v3.5.0 right now). + if ($oldversion < 2018051700) { // Just in case somebody hacks upgrade scripts or env, we really can not continue. - echo("You need to upgrade to 3.2.x or higher first!\n"); + echo("You need to upgrade to 3.5.x or higher first!\n"); exit(1); // Note this savepoint is 100% unreachable, but needed to pass the upgrade checks. - upgrade_main_savepoint(true, 2016120500); - } - - if ($oldversion < 2016122800.00) { - // Find all roles with the coursecreator archetype. - $coursecreatorroleids = $DB->get_records('role', array('archetype' => 'coursecreator'), '', 'id'); - - $context = context_system::instance(); - $capability = 'moodle/site:configview'; - - foreach ($coursecreatorroleids as $roleid => $notused) { - - // Check that the capability has not already been assigned. If it has then it's either already set - // to allow or specifically set to prohibit or prevent. - if (!$DB->record_exists('role_capabilities', array('roleid' => $roleid, 'capability' => $capability))) { - // Assign the capability. - $cap = new stdClass(); - $cap->contextid = $context->id; - $cap->roleid = $roleid; - $cap->capability = $capability; - $cap->permission = CAP_ALLOW; - $cap->timemodified = time(); - $cap->modifierid = 0; - - $DB->insert_record('role_capabilities', $cap); - } - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2016122800.00); - } - - if ($oldversion < 2017020200.01) { - - // Define index useridfrom_timeuserfromdeleted_notification (not unique) to be added to message. - $table = new xmldb_table('message'); - $index = new xmldb_index('useridfrom_timeuserfromdeleted_notification', XMLDB_INDEX_NOTUNIQUE, array('useridfrom', 'timeuserfromdeleted', 'notification')); - - // Conditionally launch add index useridfrom_timeuserfromdeleted_notification. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Define index useridto_timeusertodeleted_notification (not unique) to be added to message. - $index = new xmldb_index('useridto_timeusertodeleted_notification', XMLDB_INDEX_NOTUNIQUE, array('useridto', 'timeusertodeleted', 'notification')); - - // Conditionally launch add index useridto_timeusertodeleted_notification. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - $index = new xmldb_index('useridto', XMLDB_INDEX_NOTUNIQUE, array('useridto')); - - // Conditionally launch drop index useridto. - if ($dbman->index_exists($table, $index)) { - $dbman->drop_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017020200.01); - } - - if ($oldversion < 2017020200.02) { - - // Define index useridfrom_timeuserfromdeleted_notification (not unique) to be added to message_read. - $table = new xmldb_table('message_read'); - $index = new xmldb_index('useridfrom_timeuserfromdeleted_notification', XMLDB_INDEX_NOTUNIQUE, array('useridfrom', 'timeuserfromdeleted', 'notification')); - - // Conditionally launch add index useridfrom_timeuserfromdeleted_notification. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Define index useridto_timeusertodeleted_notification (not unique) to be added to message_read. - $index = new xmldb_index('useridto_timeusertodeleted_notification', XMLDB_INDEX_NOTUNIQUE, array('useridto', 'timeusertodeleted', 'notification')); - - // Conditionally launch add index useridto_timeusertodeleted_notification. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - $index = new xmldb_index('useridto', XMLDB_INDEX_NOTUNIQUE, array('useridto')); - - // Conditionally launch drop index useridto. - if ($dbman->index_exists($table, $index)) { - $dbman->drop_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017020200.02); - } - - if ($oldversion < 2017021300.00) { - unset_config('loginpasswordautocomplete'); - upgrade_main_savepoint(true, 2017021300.00); - } - - if ($oldversion < 2017021400.00) { - // Define field visibleoncoursepage to be added to course_modules. - $table = new xmldb_table('course_modules'); - $field = new xmldb_field('visibleoncoursepage', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'visible'); - - // Conditionally launch add field visibleoncoursepage. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017021400.00); - } - - if ($oldversion < 2017030700.00) { - - // Define field priority to be added to event. - $table = new xmldb_table('event'); - $field = new xmldb_field('priority', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'subscriptionid'); - - // Conditionally launch add field priority. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017030700.00); - } - - if ($oldversion < 2017031400.00) { - - // Define table file_conversion to be created. - $table = new xmldb_table('file_conversion'); - - // Adding fields to table file_conversion. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('usermodified', 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); - $table->add_field('sourcefileid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('targetformat', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null); - $table->add_field('status', XMLDB_TYPE_INTEGER, '10', null, null, null, '0'); - $table->add_field('statusmessage', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('converter', XMLDB_TYPE_CHAR, '255', null, null, null, null); - $table->add_field('destfileid', XMLDB_TYPE_INTEGER, '10', null, null, null, null); - $table->add_field('data', XMLDB_TYPE_TEXT, null, null, null, null, null); - - // Adding keys to table file_conversion. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('sourcefileid', XMLDB_KEY_FOREIGN, array('sourcefileid'), 'files', array('id')); - $table->add_key('destfileid', XMLDB_KEY_FOREIGN, array('destfileid'), 'files', array('id')); - - // Conditionally launch create table for file_conversion. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017031400.00); - } - - if ($oldversion < 2017040400.00) { - - // If block_course_overview is no longer present, replace with block_myoverview. - if (!file_exists($CFG->dirroot . '/blocks/course_overview/block_course_overview.php')) { - $DB->set_field('block_instances', 'blockname', 'myoverview', array('blockname' => 'course_overview')); - } - - upgrade_main_savepoint(true, 2017040400.00); - } - - if ($oldversion < 2017040401.00) { - - // If block_course_overview is no longer present, remove it. - // Note - we do not need to completely remove the block context etc because we - // have replaced all occurrences of block_course_overview with block_myoverview - // in the upgrade step above. - if (!file_exists($CFG->dirroot . '/blocks/course_overview/block_course_overview.php')) { - // Delete the block from the block table. - $DB->delete_records('block', array('name' => 'course_overview')); - // Remove capabilities. - capabilities_cleanup('block_course_overview'); - // Clean config. - unset_all_config_for_plugin('block_course_overview'); - } - - upgrade_main_savepoint(true, 2017040401.00); - } - - if ($oldversion < 2017040402.00) { - - // Define fields to be added to the 'event' table. - $table = new xmldb_table('event'); - $fieldtype = new xmldb_field('type', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, 0, 'instance'); - $fieldtimesort = new xmldb_field('timesort', XMLDB_TYPE_INTEGER, '10', null, false, null, null, 'timeduration'); - - // Conditionally launch add field. - if (!$dbman->field_exists($table, $fieldtype)) { - $dbman->add_field($table, $fieldtype); - } - - // Conditionally launch add field. - if (!$dbman->field_exists($table, $fieldtimesort)) { - $dbman->add_field($table, $fieldtimesort); - } - - // Now, define the index we will be adding. - $index = new xmldb_index('type-timesort', XMLDB_INDEX_NOTUNIQUE, array('type', 'timesort')); - - // Conditionally launch add index. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - upgrade_main_savepoint(true, 2017040402.00); - } - - if ($oldversion < 2017040700.01) { - - // Define table oauth2_issuer to be created. - $table = new xmldb_table('oauth2_issuer'); - - // Adding fields to table oauth2_issuer. - $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('usermodified', 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('image', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('baseurl', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('clientid', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('clientsecret', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('loginscopes', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('loginscopesoffline', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('loginparams', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('loginparamsoffline', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('alloweddomains', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('scopessupported', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('showonloginpage', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '1'); - $table->add_field('enabled', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '1'); - $table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table oauth2_issuer. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - - // Conditionally launch create table for oauth2_issuer. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017040700.01); - } - - if ($oldversion < 2017040700.02) { - - // Define table oauth2_endpoint to be created. - $table = new xmldb_table('oauth2_endpoint'); - - // Adding fields to table oauth2_endpoint. - $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('usermodified', 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('url', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('issuerid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table oauth2_endpoint. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('issuer_id_key', XMLDB_KEY_FOREIGN, array('issuerid'), 'oauth2_issuer', array('id')); - - // Conditionally launch create table for oauth2_endpoint. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017040700.02); - } - - if ($oldversion < 2017040700.03) { - - // Define table oauth2_system_account to be created. - $table = new xmldb_table('oauth2_system_account'); - - // Adding fields to table oauth2_system_account. - $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('usermodified', 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('refreshtoken', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('grantedscopes', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('username', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('email', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - - // Adding keys to table oauth2_system_account. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('issueridkey', XMLDB_KEY_FOREIGN_UNIQUE, array('issuerid'), 'oauth2_issuer', array('id')); - - // Conditionally launch create table for oauth2_system_account. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017040700.03); - } - - if ($oldversion < 2017040700.04) { - - // Define table oauth2_user_field_mapping to be created. - $table = new xmldb_table('oauth2_user_field_mapping'); - - // Adding fields to table oauth2_user_field_mapping. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('timemodified', 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('usermodified', 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('externalfield', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null); - $table->add_field('internalfield', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table oauth2_user_field_mapping. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('issuerkey', XMLDB_KEY_FOREIGN, array('issuerid'), 'oauth2_issuer', array('id')); - $table->add_key('uniqinternal', XMLDB_KEY_UNIQUE, array('issuerid', 'internalfield')); - - // Conditionally launch create table for oauth2_user_field_mapping. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017040700.04); - } - - if ($oldversion < 2017041801.00) { - - // Define table course_completion_defaults to be created. - $table = new xmldb_table('course_completion_defaults'); - - // Adding fields to table course_completion_defaults. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('module', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('completion', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0'); - $table->add_field('completionview', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0'); - $table->add_field('completionusegrade', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0'); - $table->add_field('completionexpected', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); - $table->add_field('customrules', XMLDB_TYPE_TEXT, null, null, null, null, null); - - // Adding keys to table course_completion_defaults. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('module', XMLDB_KEY_FOREIGN, array('module'), 'modules', array('id')); - $table->add_key('course', XMLDB_KEY_FOREIGN, array('course'), 'course', array('id')); - - // Adding indexes to table course_completion_defaults. - $table->add_index('coursemodule', XMLDB_INDEX_UNIQUE, array('course', 'module')); - - // Conditionally launch create table for course_completion_defaults. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - upgrade_main_savepoint(true, 2017041801.00); - } - - if ($oldversion < 2017050500.01) { - // Get the list of parent event IDs. - $sql = "SELECT DISTINCT repeatid - FROM {event} - WHERE repeatid <> 0"; - $parentids = array_keys($DB->get_records_sql($sql)); - // Check if there are repeating events we need to process. - if (!empty($parentids)) { - // The repeat IDs of parent events should match their own ID. - // So we need to update parent events that have non-matching IDs and repeat IDs. - list($insql, $params) = $DB->get_in_or_equal($parentids); - $updatesql = "UPDATE {event} - SET repeatid = id - WHERE id <> repeatid - AND id $insql"; - $DB->execute($updatesql, $params); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017050500.01); - } - - if ($oldversion < 2017050500.02) { - // MDL-58684: - // Remove all portfolio_tempdata records as these may contain serialized \file_system type objects, which are now unable to - // be unserialized because of changes to the file storage API made in MDL-46375. Portfolio now stores an id reference to - // files instead of the object. - // These records are normally removed after a successful export, however, can be left behind if the user abandons the - // export attempt (a stale record). Additionally, each stale record cannot be reused and is normally cleaned up by the cron - // task core\task\portfolio_cron_task. Since the cron task tries to unserialize them, and generates a warning, we'll remove - // all records here. - $DB->delete_records_select('portfolio_tempdata', 'id > ?', [0]); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017050500.02); - } - - if ($oldversion < 2017050900.01) { - // Create adhoc task for upgrading of existing calendar events. - $record = new \stdClass(); - $record->classname = '\core\task\refresh_mod_calendar_events_task'; - $record->component = 'core'; - - // 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, 2017050900.01); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017061201.00) { - $table = new xmldb_table('course_sections'); - $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'availability'); - - // Define a field 'timemodified' in the 'course_sections' table. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - upgrade_main_savepoint(true, 2017061201.00); - } - - if ($oldversion < 2017061301.00) { - // Check if the value of 'navcourselimit' is set to the old default value, if so, change it to the new default. - if ($CFG->navcourselimit == 20) { - set_config('navcourselimit', 10); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017061301.00); - } - - if ($oldversion < 2017071000.00) { - - // Define field requireconfirmation to be added to oauth2_issuer. - $table = new xmldb_table('oauth2_issuer'); - $field = new xmldb_field('requireconfirmation', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '1', 'sortorder'); - - // Conditionally launch add field requireconfirmation. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017071000.00); - } - - if ($oldversion < 2017071001.00) { - - // Define field timemodified to be added to block_instances. - $table = new xmldb_table('block_instances'); - $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, - null, null, 'configdata'); - - // Conditionally launch add field timemodified. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - - // Set field to current time. - $DB->set_field('block_instances', 'timemodified', time()); - - // Changing nullability of field timemodified on table block_instances to not null. - $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, - null, null, 'configdata'); - - // Launch change of nullability for field timemodified. - $dbman->change_field_notnull($table, $field); - - // Define index timemodified (not unique) to be added to block_instances. - $index = new xmldb_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified')); - - // Conditionally launch add index timemodified. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - } - - // Define field timecreated to be added to block_instances. - $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, null, - null, null, 'configdata'); - - // Conditionally launch add field timecreated. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - - // Set field to current time. - $DB->set_field('block_instances', 'timecreated', time()); - - // Changing nullability of field timecreated on table block_instances to not null. - $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, - null, null, 'configdata'); - - // Launch change of nullability for field timecreated. - $dbman->change_field_notnull($table, $field); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017071001.00); - } - - if ($oldversion < 2017071100.00 ) { - // Clean old upgrade setting not used anymore. - unset_config('upgrade_minmaxgradestepignored'); - upgrade_main_savepoint(true, 2017071100.00); - } - - if ($oldversion < 2017072000.02) { - - // Define table analytics_models to be created. - $table = new xmldb_table('analytics_models'); - - // Adding fields to table analytics_models. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0'); - $table->add_field('trained', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0'); - $table->add_field('target', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); - $table->add_field('indicators', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('timesplitting', XMLDB_TYPE_CHAR, '255', null, null, null, null); - $table->add_field('version', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, null, null, null); - $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table analytics_models. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - - // Adding indexes to table analytics_models. - $table->add_index('enabledandtrained', XMLDB_INDEX_NOTUNIQUE, array('enabled', 'trained')); - - // Conditionally launch create table for analytics_models. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Define table analytics_models_log to be created. - $table = new xmldb_table('analytics_models_log'); - - // Adding fields to table analytics_models_log. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('modelid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('version', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('target', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); - $table->add_field('indicators', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); - $table->add_field('timesplitting', XMLDB_TYPE_CHAR, '255', null, null, null, null); - $table->add_field('score', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, '0'); - $table->add_field('info', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('dir', 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('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table analytics_models_log. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - - // Adding indexes to table analytics_models_log. - $table->add_index('modelid', XMLDB_INDEX_NOTUNIQUE, array('modelid')); - - // Conditionally launch create table for analytics_models_log. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Define table analytics_predictions to be created. - $table = new xmldb_table('analytics_predictions'); - - // Adding fields to table analytics_predictions. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('modelid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('sampleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('rangeindex', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, null); - $table->add_field('prediction', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null); - $table->add_field('predictionscore', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null); - $table->add_field('calculations', 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 analytics_predictions. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - - // Adding indexes to table analytics_predictions. - $table->add_index('modelidandcontextid', XMLDB_INDEX_NOTUNIQUE, array('modelid', 'contextid')); - - // Conditionally launch create table for analytics_predictions. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Define table analytics_train_samples to be created. - $table = new xmldb_table('analytics_train_samples'); - - // Adding fields to table analytics_train_samples. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('modelid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('analysableid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('timesplitting', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); - $table->add_field('fileid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('sampleids', 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 analytics_train_samples. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - - // Adding indexes to table analytics_train_samples. - $table->add_index('modelidandanalysableidandtimesplitting', XMLDB_INDEX_NOTUNIQUE, - array('modelid', 'analysableid', 'timesplitting')); - - // Conditionally launch create table for analytics_train_samples. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Define table analytics_predict_ranges to be created. - $table = new xmldb_table('analytics_predict_ranges'); - - // Adding fields to table analytics_predict_ranges. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('modelid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('analysableid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('timesplitting', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); - $table->add_field('rangeindex', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); - - // Adding keys to table analytics_predict_ranges. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - - // Adding indexes to table analytics_predict_ranges. - $table->add_index('modelidandanalysableidandtimesplitting', XMLDB_INDEX_NOTUNIQUE, - array('modelid', 'analysableid', 'timesplitting')); - - // Conditionally launch create table for analytics_predict_ranges. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Define table analytics_used_files to be created. - $table = new xmldb_table('analytics_used_files'); - - // Adding fields to table analytics_used_files. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('modelid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); - $table->add_field('fileid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); - $table->add_field('action', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null); - $table->add_field('time', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); - - // Adding keys to table analytics_used_files. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - - // Adding indexes to table analytics_used_files. - $table->add_index('modelidandfileidandaction', XMLDB_INDEX_NOTUNIQUE, array('modelid', 'fileid', 'action')); - - // Conditionally launch create table for analytics_used_files. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017072000.02); - } - - if ($oldversion < 2017072700.01) { - // Changing nullability of field email on table oauth2_system_account to null. - $table = new xmldb_table('oauth2_system_account'); - $field = new xmldb_field('email', XMLDB_TYPE_TEXT, null, null, null, null, null, 'grantedscopes'); - - // Launch change of nullability for field email. - $dbman->change_field_notnull($table, $field); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017072700.01); - } - - if ($oldversion < 2017072700.02) { - - // If the site was previously registered with http://hub.moodle.org change the registration to - // point to https://moodle.net - this is the correct hub address using https protocol. - $oldhuburl = "http://hub.moodle.org"; - $newhuburl = "https://moodle.net"; - $cleanoldhuburl = preg_replace('/[^A-Za-z0-9_-]/i', '', $oldhuburl); - $cleannewhuburl = preg_replace('/[^A-Za-z0-9_-]/i', '', $newhuburl); - - // Update existing registration. - $DB->execute("UPDATE {registration_hubs} SET hubname = ?, huburl = ? WHERE huburl = ?", - ['Moodle.net', $newhuburl, $oldhuburl]); - - // Update settings of existing registration. - $sqlnamelike = $DB->sql_like('name', '?'); - $entries = $DB->get_records_sql("SELECT * FROM {config_plugins} where plugin=? and " . $sqlnamelike, - ['hub', '%' . $DB->sql_like_escape('_' . $cleanoldhuburl)]); - foreach ($entries as $entry) { - $newname = substr($entry->name, 0, -strlen($cleanoldhuburl)) . $cleannewhuburl; - try { - $DB->update_record('config_plugins', ['id' => $entry->id, 'name' => $newname]); - } catch (dml_exception $e) { - // Entry with new name already exists, remove the one with an old name. - $DB->delete_records('config_plugins', ['id' => $entry->id]); - } - } - - // Update published courses. - $DB->execute('UPDATE {course_published} SET huburl = ? WHERE huburl = ?', [$newhuburl, $oldhuburl]); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017072700.02); - } - - if ($oldversion < 2017080700.01) { - - // Get the table by its previous name. - $table = new xmldb_table('analytics_predict_ranges'); - if ($dbman->table_exists($table)) { - - // We can only accept this because we are in master. - $DB->delete_records('analytics_predictions'); - $DB->delete_records('analytics_used_files', array('action' => 'predicted')); - $DB->delete_records('analytics_predict_ranges'); - - // Define field sampleids to be added to analytics_predict_ranges (renamed below to analytics_predict_samples). - $field = new xmldb_field('sampleids', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null, 'rangeindex'); - - // Conditionally launch add field sampleids. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Define field timemodified to be added to analytics_predict_ranges (renamed below to analytics_predict_samples). - $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'timecreated'); - - // Conditionally launch add field timemodified. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Rename the table to its new name. - $dbman->rename_table($table, 'analytics_predict_samples'); - } - - $table = new xmldb_table('analytics_predict_samples'); - - $index = new xmldb_index('modelidandanalysableidandtimesplitting', XMLDB_INDEX_NOTUNIQUE, - array('modelid', 'analysableid', 'timesplitting')); - - // Conditionally launch drop index. - if ($dbman->index_exists($table, $index)) { - $dbman->drop_index($table, $index); - } - - $index = new xmldb_index('modelidandanalysableidandtimesplittingandrangeindex', XMLDB_INDEX_NOTUNIQUE, - array('modelid', 'analysableid', 'timesplitting', 'rangeindex')); - - // Conditionally launch add index. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017080700.01); - } - - if ($oldversion < 2017082200.00) { - $plugins = ['radius', 'fc', 'nntp', 'pam', 'pop3', 'imap']; - - foreach ($plugins as $plugin) { - // Check to see if the plugin exists on disk. - // If it does not, remove the config for it. - if (!file_exists($CFG->dirroot . "/auth/{$plugin}/auth.php")) { - // Clean config. - unset_all_config_for_plugin("auth_{$plugin}"); - } - } - upgrade_main_savepoint(true, 2017082200.00); - } - - if ($oldversion < 2017082200.01) { - - // Define table analytics_indicator_calc to be created. - $table = new xmldb_table('analytics_indicator_calc'); - - // Adding fields to table analytics_indicator_calc. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('starttime', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('endtime', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('sampleorigin', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); - $table->add_field('sampleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('indicator', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); - $table->add_field('value', XMLDB_TYPE_NUMBER, '10, 2', null, null, null, null); - $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table analytics_indicator_calc. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - - // Adding indexes to table analytics_indicator_calc. - $table->add_index('starttime-endtime-contextid', XMLDB_INDEX_NOTUNIQUE, array('starttime', 'endtime', 'contextid')); - - // Conditionally launch create table for analytics_indicator_calc. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017082200.01); - } - - if ($oldversion < 2017082500.00) { - // Handle FKs for the table 'analytics_models_log'. - $table = new xmldb_table('analytics_models_log'); - - // Remove the existing index before adding FK (which creates an index). - $index = new xmldb_index('modelid', XMLDB_INDEX_NOTUNIQUE, array('modelid')); - - // Conditionally launch drop index. - if ($dbman->index_exists($table, $index)) { - $dbman->drop_index($table, $index); - } - - // Now, add the FK. - $key = new xmldb_key('modelid', XMLDB_KEY_FOREIGN, array('modelid'), 'analytics_models', array('id')); - $dbman->add_key($table, $key); - - // Handle FKs for the table 'analytics_predictions'. - $table = new xmldb_table('analytics_predictions'); - $key = new xmldb_key('modelid', XMLDB_KEY_FOREIGN, array('modelid'), 'analytics_models', array('id')); - $dbman->add_key($table, $key); - - $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id')); - $dbman->add_key($table, $key); - - // Handle FKs for the table 'analytics_train_samples'. - $table = new xmldb_table('analytics_train_samples'); - $key = new xmldb_key('modelid', XMLDB_KEY_FOREIGN, array('modelid'), 'analytics_models', array('id')); - $dbman->add_key($table, $key); - - $key = new xmldb_key('fileid', XMLDB_KEY_FOREIGN, array('fileid'), 'files', array('id')); - $dbman->add_key($table, $key); - - // Handle FKs for the table 'analytics_predict_samples'. - $table = new xmldb_table('analytics_predict_samples'); - $key = new xmldb_key('modelid', XMLDB_KEY_FOREIGN, array('modelid'), 'analytics_models', array('id')); - $dbman->add_key($table, $key); - - // Handle FKs for the table 'analytics_used_files'. - $table = new xmldb_table('analytics_used_files'); - $key = new xmldb_key('modelid', XMLDB_KEY_FOREIGN, array('modelid'), 'analytics_models', array('id')); - $dbman->add_key($table, $key); - - $key = new xmldb_key('fileid', XMLDB_KEY_FOREIGN, array('fileid'), 'files', array('id')); - $dbman->add_key($table, $key); - - // Handle FKs for the table 'analytics_indicator_calc'. - $table = new xmldb_table('analytics_indicator_calc'); - $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id')); - $dbman->add_key($table, $key); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017082500.00); - } - - if ($oldversion < 2017082800.00) { - - // Changing type of field prediction on table analytics_predictions to number. - $table = new xmldb_table('analytics_predictions'); - $field = new xmldb_field('prediction', XMLDB_TYPE_NUMBER, '10, 2', null, XMLDB_NOTNULL, null, null, 'rangeindex'); - - // Launch change of type for field prediction. - $dbman->change_field_type($table, $field); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017082800.00); - } - - if ($oldversion < 2017090700.01) { - - // Define table analytics_prediction_actions to be created. - $table = new xmldb_table('analytics_prediction_actions'); - - // Adding fields to table analytics_prediction_actions. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('predictionid', 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('actionname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); - $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table analytics_prediction_actions. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('predictionid', XMLDB_KEY_FOREIGN, array('predictionid'), 'analytics_predictions', array('id')); - $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); - - // Adding indexes to table analytics_prediction_actions. - $table->add_index('predictionidanduseridandactionname', XMLDB_INDEX_NOTUNIQUE, - array('predictionid', 'userid', 'actionname')); - - // Conditionally launch create table for analytics_prediction_actions. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017090700.01); - } - - if ($oldversion < 2017091200.00) { - // Force all messages to be reindexed. - set_config('core_message_message_sent_lastindexrun', '0', 'core_search'); - set_config('core_message_message_received_lastindexrun', '0', 'core_search'); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017091200.00); - } - - if ($oldversion < 2017091201.00) { - // Define field userid to be added to task_adhoc. - $table = new xmldb_table('task_adhoc'); - $field = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'customdata'); - - // Conditionally launch add field userid. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - $key = new xmldb_key('useriduser', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); - - // Launch add key userid_user. - $dbman->add_key($table, $key); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017091201.00); - } - - if ($oldversion < 2017092201.00) { - - // Remove duplicate registrations. - $newhuburl = "https://moodle.net"; - $registrations = $DB->get_records('registration_hubs', ['huburl' => $newhuburl], 'confirmed DESC, id ASC'); - if (count($registrations) > 1) { - $reg = array_shift($registrations); - $DB->delete_records_select('registration_hubs', 'huburl = ? AND id <> ?', [$newhuburl, $reg->id]); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017092201.00); - } - - if ($oldversion < 2017092202.00) { - - if (!file_exists($CFG->dirroot . '/blocks/messages/block_messages.php')) { - - // Delete instances. - $instances = $DB->get_records_list('block_instances', 'blockname', ['messages']); - $instanceids = array_keys($instances); - - if (!empty($instanceids)) { - $DB->delete_records_list('block_positions', 'blockinstanceid', $instanceids); - $DB->delete_records_list('block_instances', 'id', $instanceids); - list($sql, $params) = $DB->get_in_or_equal($instanceids, SQL_PARAMS_NAMED); - $params['contextlevel'] = CONTEXT_BLOCK; - $DB->delete_records_select('context', "contextlevel=:contextlevel AND instanceid " . $sql, $params); - - $preferences = array(); - foreach ($instances as $instanceid => $instance) { - $preferences[] = 'block' . $instanceid . 'hidden'; - $preferences[] = 'docked_block_instance_' . $instanceid; - } - $DB->delete_records_list('user_preferences', 'name', $preferences); - } - - // Delete the block from the block table. - $DB->delete_records('block', array('name' => 'messages')); - - // Remove capabilities. - capabilities_cleanup('block_messages'); - - // Clean config. - unset_all_config_for_plugin('block_messages'); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017092202.00); - } - - if ($oldversion < 2017092700.00) { - - // Rename several fields in registration data to match the names of the properties that are sent to moodle.net. - $renames = [ - 'site_address_httpsmoodlenet' => 'site_street_httpsmoodlenet', - 'site_region_httpsmoodlenet' => 'site_regioncode_httpsmoodlenet', - 'site_country_httpsmoodlenet' => 'site_countrycode_httpsmoodlenet']; - foreach ($renames as $oldparamname => $newparamname) { - try { - $DB->execute("UPDATE {config_plugins} SET name = ? WHERE name = ? AND plugin = ?", - [$newparamname, $oldparamname, 'hub']); - } catch (dml_exception $e) { - // Exception can happen if the config value with the new name already exists, ignore it and move on. - } - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017092700.00); - } - - if ($oldversion < 2017092900.00) { - // Define field categoryid to be added to event. - $table = new xmldb_table('event'); - $field = new xmldb_field('categoryid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'format'); - - // Conditionally launch add field categoryid. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Add the categoryid key. - $key = new xmldb_key('categoryid', XMLDB_KEY_FOREIGN, array('categoryid'), 'course_categories', array('id')); - $dbman->add_key($table, $key); - - // Add a new index for groupid/courseid/categoryid/visible/userid. - // Do this before we remove the old index. - $index = new xmldb_index('groupid-courseid-categoryid-visible-userid', XMLDB_INDEX_NOTUNIQUE, array('groupid', 'courseid', 'categoryid', 'visible', 'userid')); - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Drop the old index. - $index = new xmldb_index('groupid-courseid-visible-userid', XMLDB_INDEX_NOTUNIQUE, array('groupid', 'courseid', 'visible', 'userid')); - if ($dbman->index_exists($table, $index)) { - $dbman->drop_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017092900.00); - } - - if ($oldversion < 2017100900.00) { - // Add index on time modified to grade_outcomes_history, grade_categories_history, - // grade_items_history, and scale_history. - $table = new xmldb_table('grade_outcomes_history'); - $index = new xmldb_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified')); - - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - $table = new xmldb_table('grade_items_history'); - $index = new xmldb_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified')); - - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - $table = new xmldb_table('grade_categories_history'); - $index = new xmldb_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified')); - - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - $table = new xmldb_table('scale_history'); - $index = new xmldb_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified')); - - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017100900.00); - } - - if ($oldversion < 2017101000.00) { - - // Define table analytics_used_analysables to be created. - $table = new xmldb_table('analytics_used_analysables'); - - // Adding fields to table analytics_used_analysables. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('modelid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('action', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null); - $table->add_field('analysableid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('timeanalysed', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table analytics_used_analysables. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('modelid', XMLDB_KEY_FOREIGN, array('modelid'), 'analytics_models', array('id')); - - // Adding indexes to table analytics_used_analysables. - $table->add_index('modelid-action', XMLDB_INDEX_NOTUNIQUE, array('modelid', 'action')); - - // Conditionally launch create table for analytics_used_analysables. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017101000.00); - } - - if ($oldversion < 2017101000.01) { - // Define field override to be added to course_modules_completion. - $table = new xmldb_table('course_modules_completion'); - $field = new xmldb_field('overrideby', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'viewed'); - - // Conditionally launch add field override. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017101000.01); - } - - if ($oldversion < 2017101000.02) { - // Define field 'timestart' to be added to 'analytics_predictions'. - $table = new xmldb_table('analytics_predictions'); - $field = new xmldb_field('timestart', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'timecreated'); - - // Conditionally launch add field 'timestart'. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Define field 'timeend' to be added to 'analytics_predictions'. - $field = new xmldb_field('timeend', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'timestart'); - - // Conditionally launch add field 'timeend'. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017101000.02); - } - - if ($oldversion < 2017101200.00) { - // Define table search_index_requests to be created. - $table = new xmldb_table('search_index_requests'); - - // Adding fields to table search_index_requests. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('searcharea', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); - $table->add_field('timerequested', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('partialarea', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); - $table->add_field('partialtime', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table search_index_requests. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id')); - - // Conditionally launch create table for search_index_requests. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017101200.00); - } - - // Index modification upgrade step. - if ($oldversion < 2017101300.01) { - - $table = new xmldb_table('analytics_used_files'); - - // Define index modelidandfileidandaction (not unique) to be dropped form analytics_used_files. - $index = new xmldb_index('modelidandfileidandaction', XMLDB_INDEX_NOTUNIQUE, array('modelid', 'fileid', 'action')); - - // Conditionally launch drop index modelidandfileidandaction. - if ($dbman->index_exists($table, $index)) { - $dbman->drop_index($table, $index); - } - - // Define index modelidandactionandfileid (not unique) to be dropped form analytics_used_files. - $index = new xmldb_index('modelidandactionandfileid', XMLDB_INDEX_NOTUNIQUE, array('modelid', 'action', 'fileid')); - - // Conditionally launch add index modelidandactionandfileid. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017101300.01); - } - - if ($oldversion < 2017101900.01) { - - $fs = get_file_storage(); - $models = $DB->get_records('analytics_models'); - foreach ($models as $model) { - $files = $fs->get_directory_files(\context_system::instance()->id, 'analytics', 'unlabelled', $model->id, - '/analysable/', true, true); - foreach ($files as $file) { - $file->delete(); - } - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017101900.01); - } - - if ($oldversion < 2017101900.02) { - // Create adhoc task for upgrading of existing calendar events. - $record = new \stdClass(); - $record->classname = '\core\task\refresh_mod_calendar_events_task'; - $record->component = 'core'; - - // 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, 2017101900.02); - } - - if ($oldversion < 2017102100.01) { - // We will need to force them onto ssl if loginhttps is set. - if (!empty($CFG->loginhttps)) { - set_config('overridetossl', 1); - } - // Loginhttps should no longer be set. - unset_config('loginhttps'); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017102100.01); - } - - if ($oldversion < 2017110300.01) { - - // Define field categoryid to be added to event_subscriptions. - $table = new xmldb_table('event_subscriptions'); - $field = new xmldb_field('categoryid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'url'); - - // Conditionally launch add field categoryid. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017110300.01); - } - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017111300.02) { - - // Define field basicauth to be added to oauth2_issuer. - $table = new xmldb_table('oauth2_issuer'); - $field = new xmldb_field('basicauth', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'showonloginpage'); - - // Conditionally launch add field basicauth. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017111300.02); - } - - if ($oldversion < 2017121200.00) { - - // Define key subscriptionid (foreign) to be added to event. - $table = new xmldb_table('event'); - $key = new xmldb_key('subscriptionid', XMLDB_KEY_FOREIGN, array('subscriptionid'), 'event_subscriptions', array('id')); - - // Launch add key subscriptionid. - $dbman->add_key($table, $key); - - // Define index uuid (not unique) to be added to event. - $table = new xmldb_table('event'); - $index = new xmldb_index('uuid', XMLDB_INDEX_NOTUNIQUE, array('uuid')); - - // Conditionally launch add index uuid. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017121200.00); - } - - if ($oldversion < 2017121900.00) { - - // Define table role_allow_view to be created. - $table = new xmldb_table('role_allow_view'); - - // Adding fields to table role_allow_view. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('roleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('allowview', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table role_allow_view. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('roleid', XMLDB_KEY_FOREIGN, array('roleid'), 'role', array('id')); - $table->add_key('allowview', XMLDB_KEY_FOREIGN, array('allowview'), 'role', array('id')); - - // Conditionally launch create table for role_allow_view. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - $index = new xmldb_index('roleid-allowview', XMLDB_INDEX_UNIQUE, array('roleid', 'allowview')); - - // Conditionally launch add index roleid. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - $roles = $DB->get_records('role', array(), 'sortorder ASC'); - - $DB->delete_records('role_allow_view'); - foreach ($roles as $role) { - foreach ($roles as $allowedrole) { - $record = new stdClass(); - $record->roleid = $role->id; - $record->allowview = $allowedrole->id; - $DB->insert_record('role_allow_view', $record); - } - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017121900.00); - } - - if ($oldversion < 2017122200.01) { - - // Define field indexpriority to be added to search_index_requests. Allow null initially. - $table = new xmldb_table('search_index_requests'); - $field = new xmldb_field('indexpriority', XMLDB_TYPE_INTEGER, '10', - null, null, null, null, 'partialtime'); - - // Conditionally add field. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - - // Set existing values to 'normal' value (100). - $DB->set_field('search_index_requests', 'indexpriority', 100); - - // Now make the field 'NOT NULL'. - $field = new xmldb_field('indexpriority', XMLDB_TYPE_INTEGER, '10', - null, XMLDB_NOTNULL, null, null, 'partialtime'); - $dbman->change_field_notnull($table, $field); - } - - // Define index indexprioritytimerequested (not unique) to be added to search_index_requests. - $index = new xmldb_index('indexprioritytimerequested', XMLDB_INDEX_NOTUNIQUE, - array('indexpriority', 'timerequested')); - - // Conditionally launch add index indexprioritytimerequested. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2017122200.01); - } - - if ($oldversion < 2018020500.00) { - - $topcategory = new stdClass(); - $topcategory->name = 'top'; // A non-real name for the top category. It will be localised at the display time. - $topcategory->info = ''; - $topcategory->parent = 0; - $topcategory->sortorder = 0; - - // Get the total record count - used for the progress bar. - $total = $DB->count_records_sql("SELECT COUNT(DISTINCT contextid) FROM {question_categories} WHERE parent = 0"); - - // Get the records themselves - a list of contextids. - $rs = $DB->get_recordset_sql("SELECT DISTINCT contextid FROM {question_categories} WHERE parent = 0"); - - // For each context, create a single top-level category. - $i = 0; - $pbar = new progress_bar('createtopquestioncategories', 500, true); - foreach ($rs as $contextid => $notused) { - $topcategory->contextid = $contextid; - $topcategory->stamp = make_unique_id_code(); - - $topcategoryid = $DB->insert_record('question_categories', $topcategory); - - $DB->set_field_select('question_categories', 'parent', $topcategoryid, - 'contextid = ? AND id <> ? AND parent = 0', - array($contextid, $topcategoryid)); - - // Update progress. - $i++; - $pbar->update($i, $total, "Creating top-level question categories - $i/$total."); - } - - $rs->close(); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018020500.00); - } - - if ($oldversion < 2018022800.02) { - // Define index taggeditem (unique) to be dropped form tag_instance. - $table = new xmldb_table('tag_instance'); - $index = new xmldb_index('taggeditem', XMLDB_INDEX_UNIQUE, array('component', - 'itemtype', 'itemid', 'tiuserid', 'tagid')); - - // Conditionally launch drop index taggeditem. - if ($dbman->index_exists($table, $index)) { - $dbman->drop_index($table, $index); - } - - $index = new xmldb_index('taggeditem', XMLDB_INDEX_UNIQUE, array('component', - 'itemtype', 'itemid', 'contextid', 'tiuserid', 'tagid')); - - // Conditionally launch add index taggeditem. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018022800.02); - } - - if ($oldversion < 2018022800.03) { - - // Define field multiplecontexts to be added to tag_area. - $table = new xmldb_table('tag_area'); - $field = new xmldb_field('multiplecontexts', XMLDB_TYPE_INTEGER, '1', null, - XMLDB_NOTNULL, null, '0', 'showstandard'); - - // Conditionally launch add field multiplecontexts. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018022800.03); - } - - if ($oldversion < 2018032200.01) { - // Define table 'messages' to be created. - $table = new xmldb_table('messages'); - - // Adding fields to table 'messages'. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('useridfrom', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('conversationid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('subject', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('fullmessage', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('fullmessageformat', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, 0); - $table->add_field('fullmessagehtml', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('smallmessage', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table 'messages'. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('useridfrom', XMLDB_KEY_FOREIGN, array('useridfrom'), 'user', array('id')); - $table->add_key('conversationid', XMLDB_KEY_FOREIGN, array('conversationid'), 'message_conversations', array('id')); - - // Conditionally launch create table for 'messages'. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Define table 'message_conversations' to be created. - $table = new xmldb_table('message_conversations'); - - // Adding fields to table 'message_conversations'. - $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); - - // Adding keys to table 'message_conversations'. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - - // Conditionally launch create table for 'message_conversations'. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Define table 'message_conversation_members' to be created. - $table = new xmldb_table('message_conversation_members'); - - // Adding fields to table 'message_conversation_members'. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('conversationid', 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('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table 'message_conversation_members'. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('conversationid', XMLDB_KEY_FOREIGN, array('conversationid'), 'message_conversations', array('id')); - $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); - - // Conditionally launch create table for 'message_conversation_members'. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Define table 'message_user_actions' to be created. - $table = new xmldb_table('message_user_actions'); - - // Adding fields to table 'message_user_actions'. - $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('messageid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('action', 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 'message_user_actions'. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); - $table->add_key('messageid', XMLDB_KEY_FOREIGN, array('messageid'), 'messages', array('id')); - - // Conditionally launch create table for 'message_user_actions'. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Define table 'notifications' to be created. - $table = new xmldb_table('notifications'); - - // Adding fields to table 'notifications'. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('useridfrom', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('useridto', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - $table->add_field('subject', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('fullmessage', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('fullmessageformat', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, 0); - $table->add_field('fullmessagehtml', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('smallmessage', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('component', XMLDB_TYPE_CHAR, '100', null, null, null, null); - $table->add_field('eventtype', XMLDB_TYPE_CHAR, '100', null, null, null, null); - $table->add_field('contexturl', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('contexturlname', XMLDB_TYPE_TEXT, null, null, null, null, null); - $table->add_field('timeread', XMLDB_TYPE_INTEGER, '10', null, false, null, null); - $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table 'notifications'. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('useridto', XMLDB_KEY_FOREIGN, array('useridto'), 'user', array('id')); - - // Conditionally launch create table for 'notifications'. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018032200.01); - } - - if ($oldversion < 2018032200.04) { - // Define table 'message_conversations' to be updated. - $table = new xmldb_table('message_conversations'); - $field = new xmldb_field('convhash', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null, 'id'); - - // Conditionally launch add field 'convhash'. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Conditionally launch add index. - $index = new xmldb_index('convhash', XMLDB_INDEX_UNIQUE, array('convhash')); - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018032200.04); - } - - if ($oldversion < 2018032200.05) { - // Drop table that is no longer needed. - $table = new xmldb_table('message_working'); - if ($dbman->table_exists($table)) { - $dbman->drop_table($table); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018032200.05); - } - - if ($oldversion < 2018032200.06) { - // Define table 'message_user_actions' to add an index to. - $table = new xmldb_table('message_user_actions'); - - // Conditionally launch add index. - $index = new xmldb_index('userid_messageid_action', XMLDB_INDEX_UNIQUE, array('userid', 'messageid', 'action')); - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018032200.06); - } - - if ($oldversion < 2018032200.07) { - // Define table 'messages' to add an index to. - $table = new xmldb_table('messages'); - - // Conditionally launch add index. - $index = new xmldb_index('conversationid_timecreated', XMLDB_INDEX_NOTUNIQUE, array('conversationid', 'timecreated')); - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018032200.07); - } - - if ($oldversion < 2018032700.00) { - // Update default search engine to search_simpledb if global search is disabled and there is no solr index defined. - if (empty($CFG->enableglobalsearch) && empty(get_config('search_solr', 'indexname'))) { - set_config('searchengine', 'simpledb'); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018032700.00); - } - - if ($oldversion < 2018040500.01) { - - // Define field cohort to be added to theme. Allow null initially. - $table = new xmldb_table('cohort'); - $field = new xmldb_field('theme', XMLDB_TYPE_CHAR, '50', - null, null, null, null, 'timemodified'); - - // Conditionally add field. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018040500.01); - } - - if ($oldversion < 2018050900.01) { - // Update default digital age consent map according to the current legislation on each country. - $ageofdigitalconsentmap = implode(PHP_EOL, [ - '*, 16', - 'AT, 14', - 'ES, 14', - 'US, 13' - ]); - set_config('agedigitalconsentmap', $ageofdigitalconsentmap); - - // Main savepoint reached. - upgrade_main_savepoint(true, 2018050900.01); + upgrade_main_savepoint(true, 2018051700); } // Automatically generated Moodle v3.5.0 release upgrade line. diff --git a/lib/editor/atto/db/upgrade.php b/lib/editor/atto/db/upgrade.php index 177d692b59c..f181ca31db6 100644 --- a/lib/editor/atto/db/upgrade.php +++ b/lib/editor/atto/db/upgrade.php @@ -32,68 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_editor_atto_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2018041100) { - $toolbar = get_config('editor_atto', 'toolbar'); - - if (strpos($toolbar, 'recordrtc') === false) { - $glue = "\r\n"; - if (strpos($toolbar, $glue) === false) { - $glue = "\n"; - } - $groups = explode($glue, $toolbar); - // Try to put recordrtc in files group. - foreach ($groups as $i => $group) { - $parts = explode('=', $group); - if (trim($parts[0]) == 'files') { - $groups[$i] = 'files = ' . trim($parts[1]) . ', recordrtc'; - // Update config variable. - $toolbar = implode($glue, $groups); - set_config('toolbar', $toolbar, 'editor_atto'); - } - } - } - - // Atto editor savepoint reached. - upgrade_plugin_savepoint(true, 2018041100, 'editor', 'atto'); - } - - if ($oldversion < 2018051401) { - $toolbar = get_config('editor_atto', 'toolbar'); - $glue = "\r\n"; - $iconorderold = 'image, media, managefiles, recordrtc'; - $iconordernew = 'image, media, recordrtc, managefiles'; - - if (strpos($toolbar, $glue) === false) { - $glue = "\n"; - } - - $groups = explode($glue, $toolbar); - - // Reorder atto media icons if in default configuration. - foreach ($groups as $i => $group) { - $parts = explode('=', $group); - - if (trim($parts[0]) == 'files') { - if (trim(preg_replace('/,\s*/', ', ', $parts[1])) == $iconorderold) { - $groups[$i] = 'files = ' . $iconordernew; - - // Update config variable. - $toolbar = implode($glue, $groups); - set_config('toolbar', $toolbar, 'editor_atto'); - } - } - } - - // Atto editor savepoint reached. - upgrade_plugin_savepoint(true, 2018051401, 'editor', 'atto'); - } - // Automatically generated Moodle v3.5.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 ee92e97c25e..1c8d31244c5 100644 --- a/lib/editor/atto/plugins/equation/db/upgrade.php +++ b/lib/editor/atto/plugins/equation/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_atto_equation_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/lib/editor/tinymce/db/upgrade.php b/lib/editor/tinymce/db/upgrade.php index 79a3845d18c..2bebe2ee58b 100644 --- a/lib/editor/tinymce/db/upgrade.php +++ b/lib/editor/tinymce/db/upgrade.php @@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_editor_tinymce_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/lib/editor/tinymce/plugins/spellchecker/db/upgrade.php b/lib/editor/tinymce/plugins/spellchecker/db/upgrade.php index ac477042cbc..b001bf8c193 100644 --- a/lib/editor/tinymce/plugins/spellchecker/db/upgrade.php +++ b/lib/editor/tinymce/plugins/spellchecker/db/upgrade.php @@ -27,12 +27,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_tinymce_spellchecker_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 f29b48b3358..e7a1162159f 100644 --- a/message/output/email/db/upgrade.php +++ b/message/output/email/db/upgrade.php @@ -34,12 +34,6 @@ function xmldb_message_email_upgrade($oldversion) { $dbman = $DB->get_manager(); - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/message/output/jabber/db/upgrade.php b/message/output/jabber/db/upgrade.php index 3bd5656ba71..8debc873a2e 100644 --- a/message/output/jabber/db/upgrade.php +++ b/message/output/jabber/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_message_jabber_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 e34923b138b..131dfa7ad04 100644 --- a/message/output/popup/db/upgrade.php +++ b/message/output/popup/db/upgrade.php @@ -30,51 +30,7 @@ defined('MOODLE_INTERNAL') || die(); * @param int $oldversion The version that we are upgrading from */ function xmldb_message_popup_upgrade($oldversion) { - global $CFG, $DB; - - $dbman = $DB->get_manager(); - - if ($oldversion < 2016122100) { - - // Define index isread (not unique) to be added to message_popup. - $table = new xmldb_table('message_popup'); - $index = new xmldb_index('isread', XMLDB_INDEX_NOTUNIQUE, array('isread')); - - // Conditionally launch add index isread. - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - // Popup savepoint reached. - upgrade_plugin_savepoint(true, 2016122100, 'message', 'popup'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2018032800) { - // Define table message_popup_notifications to be created. - $table = new xmldb_table('message_popup_notifications'); - - // Adding fields to table message_popup_notifications. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('notificationid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); - - // Adding keys to table message_popup_notifications. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('notificationid', XMLDB_KEY_FOREIGN, array('notificationid'), 'notifications', array('id')); - - // Conditionally launch create table for message_popup_notifications. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Popup savepoint reached. - upgrade_plugin_savepoint(true, 2018032800, 'message', 'popup'); - } + global $CFG; // Automatically generated Moodle v3.5.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 803cd283aca..34648ddb39f 100644 --- a/mod/assign/feedback/comments/db/upgrade.php +++ b/mod/assign/feedback/comments/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_assignfeedback_comments_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 05b9c25376d..0b1831c358f 100644 --- a/mod/assign/feedback/editpdf/db/upgrade.php +++ b/mod/assign/feedback/editpdf/db/upgrade.php @@ -34,28 +34,6 @@ function xmldb_assignfeedback_editpdf_upgrade($oldversion) { $dbman = $DB->get_manager(); - if ($oldversion < 2017022700) { - - // Get orphaned, duplicate files and delete them. - $fs = get_file_storage(); - $sqllike = $DB->sql_like("filename", "?"); - $where = "component='assignfeedback_editpdf' AND filearea = 'importhtml' AND " . $sqllike; - $filerecords = $DB->get_records_select("files", $where, ["onlinetext-%"]); - foreach ($filerecords as $filerecord) { - $file = $fs->get_file_instance($filerecord); - $file->delete(); - } - - // Editpdf savepoint reached. - upgrade_plugin_savepoint(true, 2017022700, 'assignfeedback', 'editpdf'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 128c94e5bb4..8730f5ede4f 100644 --- a/mod/assign/feedback/file/db/upgrade.php +++ b/mod/assign/feedback/file/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_assignfeedback_file_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 4a9fecee20b..b5b875c3b0f 100644 --- a/mod/assign/submission/comments/db/upgrade.php +++ b/mod/assign/submission/comments/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_assignsubmission_comments_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 071eaef9979..20b27c903c4 100644 --- a/mod/assign/submission/file/db/upgrade.php +++ b/mod/assign/submission/file/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_assignsubmission_file_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 779f034efe2..ebd57fd5f2d 100644 --- a/mod/assign/submission/onlinetext/db/upgrade.php +++ b/mod/assign/submission/onlinetext/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_assignsubmission_onlinetext_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/mod/assignment/db/upgrade.php b/mod/assignment/db/upgrade.php index 5add638a65a..8dad393a9f4 100644 --- a/mod/assignment/db/upgrade.php +++ b/mod/assignment/db/upgrade.php @@ -24,12 +24,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_assignment_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/mod/book/db/upgrade.php b/mod/book/db/upgrade.php index 4d39fe16dcf..e41e28240c5 100644 --- a/mod/book/db/upgrade.php +++ b/mod/book/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die; function xmldb_book_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 0d0faec4532..b0ca3033bf3 100644 --- a/mod/chat/db/upgrade.php +++ b/mod/chat/db/upgrade.php @@ -25,42 +25,7 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_chat_upgrade($oldversion) { - global $CFG, $DB; - - $dbman = $DB->get_manager(); - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017111301) { - // Rename field 'system' on table 'chat_messages' as it is a reserved word in MySQL 8+. - $table = new xmldb_table('chat_messages'); - $field = new xmldb_field('system'); - if ($dbman->field_exists($table, $field)) { - $field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'groupid'); - // Extend the execution time limit of the script to 2 hours. - upgrade_set_timeout(7200); - // Rename it to 'issystem'. - $dbman->rename_field($table, $field, 'issystem'); - } - - // Rename field 'system' on table 'chat_messages_current' as it is a reserved word in MySQL 8+. - $table = new xmldb_table('chat_messages_current'); - $field = new xmldb_field('system'); - if ($dbman->field_exists($table, $field)) { - $field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'groupid'); - // Extend the execution time limit of the script to 5 minutes. - upgrade_set_timeout(300); - // Rename it to 'issystem'. - $dbman->rename_field($table, $field, 'issystem'); - } - - // Savepoint reached. - upgrade_mod_savepoint(true, 2017111301, 'chat'); - } + global $CFG; // Automatically generated Moodle v3.5.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 d2a32063617..1da59a92583 100644 --- a/mod/choice/db/upgrade.php +++ b/mod/choice/db/upgrade.php @@ -24,12 +24,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_choice_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 c4b2dd48ad8..a6ef012d287 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -24,29 +24,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_data_upgrade($oldversion) { global $CFG, $DB; - $dbman = $DB->get_manager(); - - if ($oldversion < 2017032800) { - - // Define field completionentries to be added to data. Require a number of entries to be considered complete. - $table = new xmldb_table('data'); - $field = new xmldb_field('completionentries', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'config'); - - // Conditionally launch add field timemodified. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Data savepoint reached. - upgrade_mod_savepoint(true, 2017032800, 'data'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/mod/feedback/db/upgrade.php b/mod/feedback/db/upgrade.php index 0a63cf57ef1..5239eecb721 100644 --- a/mod/feedback/db/upgrade.php +++ b/mod/feedback/db/upgrade.php @@ -42,43 +42,7 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_feedback_upgrade($oldversion) { - global $CFG, $DB; - - $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. - - if ($oldversion < 2017032800) { - - // Delete duplicated records in feedback_completed. We just keep the last record of completion. - // Related values in feedback_value won't be deleted (they won't be used and can be kept there as a backup). - $sql = "SELECT MAX(id) as maxid, userid, feedback, courseid - FROM {feedback_completed} - WHERE userid <> 0 AND anonymous_response = :notanonymous - GROUP BY userid, feedback, courseid - HAVING COUNT(id) > 1"; - $params = ['notanonymous' => 2]; // FEEDBACK_ANONYMOUS_NO. - - $duplicatedrows = $DB->get_recordset_sql($sql, $params); - foreach ($duplicatedrows as $row) { - $DB->delete_records_select('feedback_completed', 'userid = ? AND feedback = ? AND courseid = ? AND id <> ?'. - ' AND anonymous_response = ?', array( - $row->userid, - $row->feedback, - $row->courseid, - $row->maxid, - 2, // FEEDBACK_ANONYMOUS_NO. - )); - } - $duplicatedrows->close(); - - // Feedback savepoint reached. - upgrade_mod_savepoint(true, 2017032800, 'feedback'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. + global $CFG; // Automatically generated Moodle v3.5.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 a49ddf9d426..2470939e982 100644 --- a/mod/folder/db/upgrade.php +++ b/mod/folder/db/upgrade.php @@ -45,15 +45,7 @@ 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.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. + global $CFG; // Automatically generated Moodle v3.5.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 9c8fa72bd46..6cdf26fcf0c 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -47,57 +47,6 @@ function xmldb_forum_upgrade($oldversion) { $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017092200) { - - // Remove duplicate entries from forum_subscriptions. - // Find records with multiple userid/forum combinations and find the highest ID. - // Later we will remove all those entries. - $sql = " - SELECT MIN(id) as minid, userid, forum - FROM {forum_subscriptions} - GROUP BY userid, forum - HAVING COUNT(id) > 1"; - - if ($duplicatedrows = $DB->get_recordset_sql($sql)) { - foreach ($duplicatedrows as $row) { - $DB->delete_records_select('forum_subscriptions', - 'userid = :userid AND forum = :forum AND id <> :minid', (array)$row); - } - } - $duplicatedrows->close(); - - // Define key useridforum (primary) to be added to forum_subscriptions. - $table = new xmldb_table('forum_subscriptions'); - $key = new xmldb_key('useridforum', XMLDB_KEY_UNIQUE, array('userid', 'forum')); - - // Launch add key useridforum. - $dbman->add_key($table, $key); - - // Forum savepoint reached. - upgrade_mod_savepoint(true, 2017092200, 'forum'); - } - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2018032900) { - - // Define field deleted to be added to forum_posts. - $table = new xmldb_table('forum_posts'); - $field = new xmldb_field('deleted', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'mailnow'); - - // Conditionally launch add field deleted. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Forum savepoint reached. - upgrade_mod_savepoint(true, 2018032900, 'forum'); - } - // Automatically generated Moodle v3.5.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 69a277ba9df..ba2b8b6cd27 100644 --- a/mod/glossary/db/upgrade.php +++ b/mod/glossary/db/upgrade.php @@ -20,13 +20,7 @@ // before any action that may take longer time to finish. function xmldb_glossary_upgrade($oldversion) { - global $CFG, $DB; - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. + global $DB; // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/mod/imscp/db/upgrade.php b/mod/imscp/db/upgrade.php index 852bc058d5a..68384443a5e 100644 --- a/mod/imscp/db/upgrade.php +++ b/mod/imscp/db/upgrade.php @@ -31,12 +31,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_imscp_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 ef58d7868b2..3de6a43fa21 100644 --- a/mod/label/db/upgrade.php +++ b/mod/label/db/upgrade.php @@ -45,24 +45,7 @@ defined('MOODLE_INTERNAL') || die; function xmldb_label_upgrade($oldversion) { - global $CFG, $DB; - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017062800) { - // Update all records in 'course_modules' for labels to have showdescription = 1. - if ($modid = $DB->get_field('modules', 'id', ['name' => 'label'])) { - $DB->execute("UPDATE {course_modules} SET showdescription = ? WHERE module = ?", - [1, $modid]); - } - - // Label savepoint reached. - upgrade_mod_savepoint(true, 2017062800, 'label'); - } - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. + global $CFG; // Automatically generated Moodle v3.5.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 a0e1e650c54..9ad02c06da5 100644 --- a/mod/lesson/db/upgrade.php +++ b/mod/lesson/db/upgrade.php @@ -50,66 +50,7 @@ defined('MOODLE_INTERNAL') || die(); * @return bool */ function xmldb_lesson_upgrade($oldversion) { - global $CFG, $DB; - - $dbman = $DB->get_manager(); - - if ($oldversion < 2016120515) { - // Define new fields to be added to lesson. - $table = new xmldb_table('lesson'); - $field = new xmldb_field('allowofflineattempts', XMLDB_TYPE_INTEGER, '1', null, null, null, 0, 'completiontimespent'); - // Conditionally launch add field allowofflineattempts. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - // Lesson savepoint reached. - upgrade_mod_savepoint(true, 2016120515, 'lesson'); - } - if ($oldversion < 2016120516) { - // New field for lesson_timer. - $table = new xmldb_table('lesson_timer'); - $field = new xmldb_field('timemodifiedoffline', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, 0, 'completed'); - // Conditionally launch add field timemodifiedoffline. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - // Lesson savepoint reached. - upgrade_mod_savepoint(true, 2016120516, 'lesson'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017051501) { - - // Delete orphaned lesson answer and response files. - $sql = "SELECT DISTINCT f.contextid, f.component, f.filearea, f.itemid - FROM {files} f - LEFT JOIN {lesson_answers} la ON f.itemid = la.id - WHERE component = :component - AND (filearea = :fileareaanswer OR filearea = :filearearesponse) - AND la.id IS NULL"; - - $orphanedfiles = $DB->get_recordset_sql($sql, array('component' => 'mod_lesson', 'fileareaanswer' => 'page_answers', - 'filearearesponse' => 'page_responses')); - $fs = get_file_storage(); - foreach ($orphanedfiles as $file) { - $fs->delete_area_files($file->contextid, $file->component, $file->filearea, $file->itemid); - } - $orphanedfiles->close(); - - upgrade_mod_savepoint(true, 2017051501, 'lesson'); - } - - if ($oldversion < 2019062400) { - // Delete orphaned group overrides. - $DB->delete_records_select('lesson_overrides', 'groupid = 0 AND userid IS NULL'); - - upgrade_mod_savepoint(true, 2019062400, 'lesson'); - } - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. + global $CFG; // Automatically generated Moodle v3.5.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 a24dc6d270e..f5d2b10b986 100644 --- a/mod/lti/db/upgrade.php +++ b/mod/lti/db/upgrade.php @@ -63,64 +63,6 @@ function xmldb_lti_upgrade($oldversion) { $dbman = $DB->get_manager(); - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017111301) { - - // A bug in the LTI plugin incorrectly inserted a grade item for - // LTI instances which were set to not allow grading. - // The change finds any LTI which does not have grading enabled, - // and updates any grades to delete them. - - $ltis = $DB->get_recordset_sql(" - SELECT - l.id, - l.course, - l.instructorchoiceacceptgrades, - t.enabledcapability, - t.toolproxyid, - tc.value AS acceptgrades - FROM {lti} l - INNER JOIN {grade_items} gt - ON l.id = gt.iteminstance - LEFT JOIN {lti_types} t - ON t.id = l.typeid - LEFT JOIN {lti_types_config} tc - ON tc.typeid = t.id AND tc.name = 'acceptgrades' - WHERE gt.itemmodule = 'lti' - AND gt.itemtype = 'mod' - "); - - foreach ($ltis as $lti) { - $acceptgrades = true; - if (empty($lti->toolproxyid)) { - $typeacceptgrades = isset($lti->acceptgrades) ? $lti->acceptgrades : 2; - if (!($typeacceptgrades == 1 || - ($typeacceptgrades == 2 && $lti->instructorchoiceacceptgrades == 1))) { - $acceptgrades = false; - } - } else { - $enabledcapabilities = explode("\n", $lti->enabledcapability); - $acceptgrades = in_array('Result.autocreate', $enabledcapabilities); - } - - if (!$acceptgrades) { - // Required when doing CLI upgrade. - require_once($CFG->libdir . '/gradelib.php'); - grade_update('mod/lti', $lti->course, 'mod', 'lti', $lti->id, 0, null, array('deleted' => 1)); - } - - } - - $ltis->close(); - - upgrade_mod_savepoint(true, 2017111301, 'lti'); - } - // Automatically generated Moodle v3.5.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 be3c4b92896..205f53d4222 100644 --- a/mod/page/db/upgrade.php +++ b/mod/page/db/upgrade.php @@ -47,12 +47,6 @@ defined('MOODLE_INTERNAL') || die; function xmldb_page_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 0bf35336e67..289328ff8c2 100644 --- a/mod/quiz/db/upgrade.php +++ b/mod/quiz/db/upgrade.php @@ -29,124 +29,7 @@ defined('MOODLE_INTERNAL') || die(); * @param string $oldversion the version we are upgrading from. */ function xmldb_quiz_upgrade($oldversion) { - global $CFG, $DB; - - $dbman = $DB->get_manager(); - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2018020700) { - - $table = new xmldb_table('quiz_slots'); - - // Define field questioncategoryid to be added to quiz_slots. - $field = new xmldb_field('questioncategoryid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'questionid'); - // Conditionally launch add field questioncategoryid. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Define key questioncategoryid (foreign) to be added to quiz_slots. - $key = new xmldb_key('questioncategoryid', XMLDB_KEY_FOREIGN, array('questioncategoryid'), 'question_categories', ['id']); - // Launch add key questioncategoryid. - $dbman->add_key($table, $key); - - // Define field includingsubcategories to be added to quiz_slots. - $field = new xmldb_field('includingsubcategories', XMLDB_TYPE_INTEGER, '4', null, null, null, null, 'questioncategoryid'); - // Conditionally launch add field includingsubcategories. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Quiz savepoint reached. - upgrade_mod_savepoint(true, 2018020700, 'quiz'); - } - - if ($oldversion < 2018020701) { - // This SQL fetches all "random" questions from the question bank. - $fromclause = "FROM {quiz_slots} qs - JOIN {question} q ON q.id = qs.questionid - WHERE q.qtype = ?"; - - // Get the total record count - used for the progress bar. - $total = $DB->count_records_sql("SELECT count(qs.id) $fromclause", array('random')); - - // Get the records themselves. - $rs = $DB->get_recordset_sql("SELECT qs.id, q.category, q.questiontext $fromclause", array('random')); - - $a = new stdClass(); - $a->total = $total; - $a->done = 0; - - // For each question, move the configuration data to the quiz_slots table. - $pbar = new progress_bar('updatequizslotswithrandom', 500, true); - foreach ($rs as $record) { - $data = new stdClass(); - $data->id = $record->id; - $data->questioncategoryid = $record->category; - $data->includingsubcategories = empty($record->questiontext) ? 0 : 1; - $DB->update_record('quiz_slots', $data); - - // Update progress. - $a->done++; - $pbar->update($a->done, $a->total, get_string('updatequizslotswithrandomxofy', 'quiz', $a)); - } - $rs->close(); - - // Quiz savepoint reached. - upgrade_mod_savepoint(true, 2018020701, 'quiz'); - } - - if ($oldversion < 2018040700) { - - // Define field tags to be dropped from quiz_slots. This field was added earlier to master only. - $table = new xmldb_table('quiz_slots'); - $field = new xmldb_field('tags'); - - // Conditionally launch drop field quizid. - if ($dbman->field_exists($table, $field)) { - $dbman->drop_field($table, $field); - } - - // Quiz savepoint reached. - upgrade_mod_savepoint(true, 2018040700, 'quiz'); - } - - if ($oldversion < 2018040800) { - - // Define table quiz_slot_tags to be created. - $table = new xmldb_table('quiz_slot_tags'); - - // Adding fields to table quiz_slot_tags. - $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); - $table->add_field('slotid', XMLDB_TYPE_INTEGER, '10', null, null, null, null); - $table->add_field('tagid', XMLDB_TYPE_INTEGER, '10', null, null, null, null); - $table->add_field('tagname', XMLDB_TYPE_CHAR, '255', null, null, null, null); - - // Adding keys to table quiz_slot_tags. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('slotid', XMLDB_KEY_FOREIGN, array('slotid'), 'quiz_slots', array('id')); - $table->add_key('tagid', XMLDB_KEY_FOREIGN, array('tagid'), 'tag', array('id')); - - // Conditionally launch create table for quiz_slot_tags. - if (!$dbman->table_exists($table)) { - $dbman->create_table($table); - } - - // Quiz savepoint reached. - upgrade_mod_savepoint(true, 2018040800, 'quiz'); - } - - if ($oldversion < 2019062400) { - // Delete orphaned group overrides. - $DB->delete_records_select('quiz_overrides', 'groupid = 0 AND userid IS NULL'); - - upgrade_mod_savepoint(true, 2019062400, 'quiz'); - } + global $CFG; // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/mod/quiz/report/overview/db/upgrade.php b/mod/quiz/report/overview/db/upgrade.php index 251987310ba..28eed85ed59 100644 --- a/mod/quiz/report/overview/db/upgrade.php +++ b/mod/quiz/report/overview/db/upgrade.php @@ -33,12 +33,6 @@ function xmldb_quiz_overview_upgrade($oldversion) { $dbman = $DB->get_manager(); - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 af1fada050a..eea4d616b60 100644 --- a/mod/quiz/report/statistics/db/upgrade.php +++ b/mod/quiz/report/statistics/db/upgrade.php @@ -30,12 +30,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_quiz_statistics_upgrade($oldversion) { global $DB; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 845fb1766dd..e07f5c05151 100644 --- a/mod/resource/db/upgrade.php +++ b/mod/resource/db/upgrade.php @@ -47,12 +47,6 @@ defined('MOODLE_INTERNAL') || die; function xmldb_resource_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 30e8b5cfd8a..6340b83a54d 100644 --- a/mod/scorm/db/upgrade.php +++ b/mod/scorm/db/upgrade.php @@ -30,36 +30,10 @@ defined('MOODLE_INTERNAL') || die(); * @return bool */ function xmldb_scorm_upgrade($oldversion) { - global $CFG, $DB; + global $DB; $dbman = $DB->get_manager(); - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2018032300) { - set_config('scormstandard', get_config('scorm', 'scorm12standard'), 'scorm'); - unset_config('scorm12standard', 'scorm'); - - upgrade_mod_savepoint(true, 2018032300, 'scorm'); - } - - if ($oldversion < 2018041100) { - - // Changing precision of field completionscorerequired on table scorm to (10). - $table = new xmldb_table('scorm'); - $field = new xmldb_field('completionscorerequired', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'completionstatusrequired'); - - // Launch change of precision for field completionscorerequired. - $dbman->change_field_precision($table, $field); - - // Scorm savepoint reached. - upgrade_mod_savepoint(true, 2018041100, 'scorm'); - } - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/mod/survey/db/upgrade.php b/mod/survey/db/upgrade.php index 4efd2b5efca..04fe8e4368a 100644 --- a/mod/survey/db/upgrade.php +++ b/mod/survey/db/upgrade.php @@ -24,12 +24,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_survey_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 67ed7f6fdcc..733364138e3 100644 --- a/mod/url/db/upgrade.php +++ b/mod/url/db/upgrade.php @@ -47,12 +47,6 @@ defined('MOODLE_INTERNAL') || die; function xmldb_url_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 a9a049eb64e..b9f2f13482b 100644 --- a/mod/wiki/db/upgrade.php +++ b/mod/wiki/db/upgrade.php @@ -40,12 +40,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_wiki_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 47a2c2512c7..aa90b9ef17b 100644 --- a/mod/workshop/db/upgrade.php +++ b/mod/workshop/db/upgrade.php @@ -35,33 +35,10 @@ defined('MOODLE_INTERNAL') || die(); * @return bool result */ function xmldb_workshop_upgrade($oldversion) { - global $CFG, $DB; + global $DB; $dbman = $DB->get_manager(); - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2018042700) { - // Drop the old Moodle 1.x tables, thanks privacy by design for forcing me to do so finally. - - $oldtables = ['workshop_old', 'workshop_elements_old', 'workshop_rubrics_old', 'workshop_submissions_old', - 'workshop_assessments_old', 'workshop_grades_old', 'workshop_stockcomments_old', 'workshop_comments_old']; - - foreach ($oldtables as $oldtable) { - $table = new xmldb_table($oldtable); - - if ($dbman->table_exists($table)) { - $dbman->drop_table($table); - } - } - - upgrade_mod_savepoint(true, 2018042700, 'workshop'); - } - // Automatically generated Moodle v3.5.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 134339d6346..14df521a011 100644 --- a/mod/workshop/form/accumulative/db/upgrade.php +++ b/mod/workshop/form/accumulative/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_workshopform_accumulative_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 c87190dc756..7db0a54828a 100644 --- a/mod/workshop/form/comments/db/upgrade.php +++ b/mod/workshop/form/comments/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_workshopform_comments_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 27f1e328e60..7789f9b5c64 100644 --- a/mod/workshop/form/numerrors/db/upgrade.php +++ b/mod/workshop/form/numerrors/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_workshopform_numerrors_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 687a027504f..beacab49298 100644 --- a/mod/workshop/form/rubric/db/upgrade.php +++ b/mod/workshop/form/rubric/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_workshopform_rubric_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/portfolio/boxnet/db/upgrade.php b/portfolio/boxnet/db/upgrade.php index c9a9885587f..10efcfa1cf8 100644 --- a/portfolio/boxnet/db/upgrade.php +++ b/portfolio/boxnet/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_portfolio_boxnet_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/portfolio/googledocs/db/upgrade.php b/portfolio/googledocs/db/upgrade.php index 9b476ab94d8..a97753bf428 100644 --- a/portfolio/googledocs/db/upgrade.php +++ b/portfolio/googledocs/db/upgrade.php @@ -23,12 +23,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_portfolio_googledocs_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/portfolio/picasa/db/upgrade.php b/portfolio/picasa/db/upgrade.php index 93e9ef15c13..1c1068a216f 100644 --- a/portfolio/picasa/db/upgrade.php +++ b/portfolio/picasa/db/upgrade.php @@ -23,12 +23,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_portfolio_picasa_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 7f83cf07ccf..20998911418 100644 --- a/question/behaviour/manualgraded/db/upgrade.php +++ b/question/behaviour/manualgraded/db/upgrade.php @@ -30,12 +30,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_qbehaviour_manualgraded_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 f5593d6d02c..a90295b555a 100644 --- a/question/type/calculated/db/upgrade.php +++ b/question/type/calculated/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_qtype_calculated_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 f5134c83f30..357a59e5cf8 100644 --- a/question/type/ddmarker/db/upgrade.php +++ b/question/type/ddmarker/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_qtype_ddmarker_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 f6d2c2c2742..21595b6f0ec 100644 --- a/question/type/essay/db/upgrade.php +++ b/question/type/essay/db/upgrade.php @@ -30,30 +30,7 @@ defined('MOODLE_INTERNAL') || die(); * @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.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2018021800) { - - // Add "filetypeslist" column to the question type options to save the allowed file types. - $table = new xmldb_table('qtype_essay_options'); - $field = new xmldb_field('filetypeslist', XMLDB_TYPE_TEXT, null, null, null, null, null, 'responsetemplateformat'); - - // Conditionally launch add field filetypeslist. - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Essay savepoint reached. - upgrade_plugin_savepoint(true, 2018021800, 'qtype', 'essay'); - } + global $CFG; // Automatically generated Moodle v3.5.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 3814ecf7470..3f23799059f 100644 --- a/question/type/match/db/upgrade.php +++ b/question/type/match/db/upgrade.php @@ -31,12 +31,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_qtype_match_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 1505cf12b7a..c99e7354986 100644 --- a/question/type/multianswer/db/upgrade.php +++ b/question/type/multianswer/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_qtype_multianswer_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 6dd50d2eddb..1cb4329c21e 100644 --- a/question/type/multichoice/db/upgrade.php +++ b/question/type/multichoice/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_qtype_multichoice_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 4812baad9df..e13063c0d6b 100644 --- a/question/type/numerical/db/upgrade.php +++ b/question/type/numerical/db/upgrade.php @@ -30,27 +30,7 @@ defined('MOODLE_INTERNAL') || die(); * @param int $oldversion the version we are upgrading from. */ function xmldb_qtype_numerical_upgrade($oldversion) { - global $CFG, $DB; - $dbman = $DB->get_manager(); - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017121000) { - - // Changing length of field multiplier on table question_numerical_units to 38. - $table = new xmldb_table('question_numerical_units'); - $field = new xmldb_field('multiplier', XMLDB_TYPE_NUMBER, '38, 19', null, XMLDB_NOTNULL, null, '1.00000000000000000000'); - - // Launch change of length for field multiplier. - $dbman->change_field_type($table, $field); - - // Data savepoint reached. - upgrade_plugin_savepoint(true, 2017121000, 'qtype', 'numerical'); - } + global $CFG; // Automatically generated Moodle v3.5.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 908a4a0115a..c6c16f91ecc 100644 --- a/question/type/random/db/upgrade.php +++ b/question/type/random/db/upgrade.php @@ -31,12 +31,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_qtype_random_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 c1b4138acb1..7f487a82657 100644 --- a/question/type/randomsamatch/db/upgrade.php +++ b/question/type/randomsamatch/db/upgrade.php @@ -31,12 +31,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_qtype_randomsamatch_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 91f461d147c..7d0cb363c2b 100644 --- a/question/type/shortanswer/db/upgrade.php +++ b/question/type/shortanswer/db/upgrade.php @@ -32,12 +32,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_qtype_shortanswer_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/repository/boxnet/db/upgrade.php b/repository/boxnet/db/upgrade.php index 2b9788f738a..61dd59ab1ae 100644 --- a/repository/boxnet/db/upgrade.php +++ b/repository/boxnet/db/upgrade.php @@ -33,12 +33,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_repository_boxnet_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 8e9eb839ef9..8522bb6edcf 100644 --- a/repository/dropbox/db/upgrade.php +++ b/repository/dropbox/db/upgrade.php @@ -23,12 +23,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_repository_dropbox_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 58d1f3ae940..278a90ebc1b 100644 --- a/repository/flickr/db/upgrade.php +++ b/repository/flickr/db/upgrade.php @@ -32,20 +32,7 @@ defined('MOODLE_INTERNAL') || die(); * @return bool */ function xmldb_repository_flickr_upgrade($oldversion) { - global $DB; - - $dbman = $DB->get_manager(); - - if ($oldversion < 2017082200) { - // Drop legacy flickr auth tokens and nsid's. - $DB->delete_records('user_preferences', ['name' => 'flickr_']); - $DB->delete_records('user_preferences', ['name' => 'flickr__nsid']); - - upgrade_plugin_savepoint(true, 2017082200, 'repository', 'flickr'); - } - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. + global $CFG; // Automatically generated Moodle v3.5.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 b656611351e..65d14bbbd8a 100644 --- a/repository/googledocs/db/upgrade.php +++ b/repository/googledocs/db/upgrade.php @@ -23,44 +23,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_repository_googledocs_upgrade($oldversion) { global $CFG; - if ($oldversion < 2017011100) { - // Set default import formats from Google. - set_config('documentformat', 'rtf', 'googledocs'); - set_config('drawingformat', 'pdf', 'googledocs'); - set_config('presentationformat', 'pptx', 'googledocs'); - set_config('spreadsheetformat', 'xlsx', 'googledocs'); - - // Plugin savepoint reached. - upgrade_plugin_savepoint(true, 2017011100, 'repository', 'googledocs'); - } - if ($oldversion < 2017030500) { - $clientid = get_config('clientid', 'googledocs'); - $secret = get_config('secret', 'googledocs'); - - // Update from repo config to use an OAuth service. - if (!empty($clientid) && !empty($secret)) { - $issuer = \core\oauth2\api::create_standard_issuer('google'); - - $issuer->set('clientid', $clientid); - $issuer->set('secret', $secret); - - $issuer->update(); - - set_config('issuerid', $issuer->get('id'), 'googledocs'); - } - upgrade_plugin_savepoint(true, 2017030500, 'repository', 'googledocs'); - } - if ($oldversion < 2017030600) { - set_config('supportedfiles', 'both', 'googledocs'); - upgrade_plugin_savepoint(true, 2017030600, 'repository', 'googledocs'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.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 f36555ed0ab..ef9ed7ead07 100644 --- a/repository/onedrive/db/upgrade.php +++ b/repository/onedrive/db/upgrade.php @@ -24,15 +24,7 @@ defined('MOODLE_INTERNAL') || die(); * @return bool result */ function xmldb_repository_onedrive_upgrade($oldversion) { - global $DB; - - $dbman = $DB->get_manager(); - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. + global $CFG; // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. diff --git a/repository/picasa/db/upgrade.php b/repository/picasa/db/upgrade.php index e7a87c02cbb..60d0f65e749 100644 --- a/repository/picasa/db/upgrade.php +++ b/repository/picasa/db/upgrade.php @@ -23,12 +23,6 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_repository_picasa_upgrade($oldversion) { global $CFG; - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v3.4.0 release upgrade line. - // Put any upgrade step following this. - // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this.