Skip to content

Commit

Permalink
MDL-57432 upgrade: clean < 3.0.0 upgrade steps
Browse files Browse the repository at this point in the history
This just deletes all the upgrade steps previous to 3.0.0. Some
small adjustments, like adding missing MOODLE_INTERNAL or tweaking
globals can also be applied when needed.

Also includes an upgrade step to prevent upgrading from any
version < 2015111600 (v3.0.0) as anti-cheating measure.

Next commit will get rid of/deprecate all the upgradelib functions
not used anymore in codebase.
  • Loading branch information
stronk7 authored and danpoltawski committed Jul 10, 2017
1 parent d18f160 commit 29af7b0
Show file tree
Hide file tree
Showing 97 changed files with 30 additions and 3,246 deletions.
9 changes: 0 additions & 9 deletions admin/tool/customlang/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@
function xmldb_tool_customlang_upgrade($oldversion) {
global $CFG;

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
9 changes: 0 additions & 9 deletions admin/tool/log/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@
function xmldb_tool_log_upgrade($oldversion) {
global $CFG;

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
9 changes: 0 additions & 9 deletions admin/tool/log/store/database/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@
function xmldb_logstore_database_upgrade($oldversion) {
global $CFG;

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
28 changes: 1 addition & 27 deletions admin/tool/log/store/standard/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,7 @@
defined('MOODLE_INTERNAL') || die();

function xmldb_logstore_standard_upgrade($oldversion) {
global $CFG, $DB;

$dbman = $DB->get_manager();

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2016041200) {
// This could take a long time. Unfortunately, no way to know how long, and no way to do progress, so setting for 1 hour.
upgrade_set_timeout(3600);

// Define key contextid (foreign) to be added to logstore_standard_log.
$table = new xmldb_table('logstore_standard_log');
$key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id'));

// Launch add key contextid.
$dbman->add_key($table, $key);

// Standard savepoint reached.
upgrade_plugin_savepoint(true, 2016041200, 'logstore', 'standard');
}
global $CFG;

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
Expand Down
26 changes: 1 addition & 25 deletions admin/tool/monitor/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,10 @@
* @return bool always true
*/
function xmldb_tool_monitor_upgrade($oldversion) {
global $DB;
global $CFG, $DB;

$dbman = $DB->get_manager();

if ($oldversion < 2014102000) {

// Define field lastnotificationsent to be added to tool_monitor_subscriptions.
$table = new xmldb_table('tool_monitor_subscriptions');
$field = new xmldb_field('lastnotificationsent', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'timecreated');

// Conditionally launch add field lastnotificationsent.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

// Monitor savepoint reached.
upgrade_plugin_savepoint(true, 2014102000, 'tool', 'monitor');
}

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
23 changes: 1 addition & 22 deletions auth/cas/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,7 @@
* @return bool result
*/
function xmldb_auth_cas_upgrade($oldversion) {
global $CFG, $DB;

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2014111001) {
// From now on the default LDAP objectClass setting for AD has been changed, from 'user' to '(samaccounttype=805306368)'.
if (is_enabled_auth('cas')
&& ($DB->get_field('config_plugins', 'value', array('name' => 'user_type', 'plugin' => 'auth/cas')) === 'ad')
&& ($DB->get_field('config_plugins', 'value', array('name' => 'objectclass', 'plugin' => 'auth/cas')) === '')) {
// Save the backwards-compatible default setting.
set_config('objectclass', 'user', 'auth/cas');
}

upgrade_plugin_savepoint(true, 2014111001, 'auth', 'cas');
}

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
global $CFG;

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
Expand Down
23 changes: 1 addition & 22 deletions auth/ldap/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,7 @@
* @return bool result
*/
function xmldb_auth_ldap_upgrade($oldversion) {
global $CFG, $DB;

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2014111001) {
// From now on the default LDAP objectClass setting for AD has been changed, from 'user' to '(samaccounttype=805306368)'.
if (is_enabled_auth('ldap')
&& ($DB->get_field('config_plugins', 'value', array('name' => 'user_type', 'plugin' => 'auth/ldap')) === 'ad')
&& ($DB->get_field('config_plugins', 'value', array('name' => 'objectclass', 'plugin' => 'auth/ldap')) === '')) {
// Save the backwards-compatible default setting.
set_config('objectclass', 'user', 'auth/ldap');
}

upgrade_plugin_savepoint(true, 2014111001, 'auth', 'ldap');
}

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
global $CFG;

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
Expand Down
11 changes: 1 addition & 10 deletions auth/manual/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,7 @@
* @return bool result
*/
function xmldb_auth_manual_upgrade($oldversion) {
global $CFG, $DB;

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
global $CFG;

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
Expand Down
11 changes: 1 addition & 10 deletions auth/mnet/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,7 @@
* @return bool result
*/
function xmldb_auth_mnet_upgrade($oldversion) {
global $CFG, $DB;

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
global $CFG;

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
Expand Down
39 changes: 1 addition & 38 deletions blocks/badges/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,44 +43,7 @@
* @param object $block
*/
function xmldb_block_badges_upgrade($oldversion, $block) {
global $DB;

if ($oldversion < 2014062600) {
// Add this block the default blocks on /my.
$blockname = 'badges';

// Do not try to add the block if we cannot find the default my_pages entry.
// Private => 1 refers to MY_PAGE_PRIVATE.
if ($systempage = $DB->get_record('my_pages', array('userid' => null, 'private' => 1))) {
$page = new moodle_page();
$page->set_context(context_system::instance());

// Check to see if this block is already on the default /my page.
$criteria = array(
'blockname' => $blockname,
'parentcontextid' => $page->context->id,
'pagetypepattern' => 'my-index',
'subpagepattern' => $systempage->id,
);

if (!$DB->record_exists('block_instances', $criteria)) {
// Add the block to the default /my.
$page->blocks->add_region(BLOCK_POS_RIGHT);
$page->blocks->add_block($blockname, BLOCK_POS_RIGHT, 0, false, 'my-index', $systempage->id);
}
}

upgrade_block_savepoint(true, 2014062600, $blockname);
}

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
global $CFG;

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
Expand Down
39 changes: 1 addition & 38 deletions blocks/calendar_month/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,44 +43,7 @@
* @param object $block
*/
function xmldb_block_calendar_month_upgrade($oldversion, $block) {
global $DB;

if ($oldversion < 2014062600) {
// Add this block the default blocks on /my.
$blockname = 'calendar_month';

// Do not try to add the block if we cannot find the default my_pages entry.
// Private => 1 refers to MY_PAGE_PRIVATE.
if ($systempage = $DB->get_record('my_pages', array('userid' => null, 'private' => 1))) {
$page = new moodle_page();
$page->set_context(context_system::instance());

// Check to see if this block is already on the default /my page.
$criteria = array(
'blockname' => $blockname,
'parentcontextid' => $page->context->id,
'pagetypepattern' => 'my-index',
'subpagepattern' => $systempage->id,
);

if (!$DB->record_exists('block_instances', $criteria)) {
// Add the block to the default /my.
$page->blocks->add_region(BLOCK_POS_RIGHT);
$page->blocks->add_block($blockname, BLOCK_POS_RIGHT, 0, false, 'my-index', $systempage->id);
}
}

upgrade_block_savepoint(true, 2014062600, $blockname);
}

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
global $CFG;

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
Expand Down
39 changes: 1 addition & 38 deletions blocks/calendar_upcoming/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,44 +43,7 @@
* @param object $block
*/
function xmldb_block_calendar_upcoming_upgrade($oldversion, $block) {
global $DB;

if ($oldversion < 2014062600) {
// Add this block the default blocks on /my.
$blockname = 'calendar_upcoming';

// Do not try to add the block if we cannot find the default my_pages entry.
// Private => 1 refers to MY_PAGE_PRIVATE.
if ($systempage = $DB->get_record('my_pages', array('userid' => null, 'private' => 1))) {
$page = new moodle_page();
$page->set_context(context_system::instance());

// Check to see if this block is already on the default /my page.
$criteria = array(
'blockname' => $blockname,
'parentcontextid' => $page->context->id,
'pagetypepattern' => 'my-index',
'subpagepattern' => $systempage->id,
);

if (!$DB->record_exists('block_instances', $criteria)) {
// Add the block to the default /my.
$page->blocks->add_region(BLOCK_POS_RIGHT);
$page->blocks->add_block($blockname, BLOCK_POS_RIGHT, 0, false, 'my-index', $systempage->id);
}
}

upgrade_block_savepoint(true, 2014062600, $blockname);
}

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
global $CFG;

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
Expand Down
9 changes: 0 additions & 9 deletions blocks/community/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@
function xmldb_block_community_upgrade($oldversion) {
global $CFG;

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
9 changes: 0 additions & 9 deletions blocks/completionstatus/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@
function xmldb_block_completionstatus_upgrade($oldversion, $block) {
global $CFG;

// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.

// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
Loading

0 comments on commit 29af7b0

Please sign in to comment.