MDL-28466 remove the enrol_authorize data

If there are no records, remove the plugin
This commit is contained in:
Dan Poltawski 2013-07-15 13:56:39 +08:00
parent 5710055d41
commit c2ca2d8e91
4 changed files with 37 additions and 1 deletions

View file

@ -2667,6 +2667,7 @@ function update_capabilities($component = 'moodle') {
/** /**
* Deletes cached capabilities that are no longer needed by the component. * Deletes cached capabilities that are no longer needed by the component.
* Also unassigns these capabilities from any roles that have them. * Also unassigns these capabilities from any roles that have them.
* NOTE: this function is called from lib/db/upgrade.php
* *
* @access private * @access private
* @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results' * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'

View file

@ -2259,5 +2259,39 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2013070800.01); upgrade_main_savepoint(true, 2013070800.01);
} }
if ($oldversion < 2013071500.01) {
// The enrol_authorize plugin has been removed, if there are no records
// and no plugin files then remove the plugin data.
$enrolauthorize = new xmldb_table('enrol_authorize');
$enrolauthorizerefunds = new xmldb_table('enrol_authorize_refunds');
if (!file_exists($CFG->dirroot.'/enrol/authorize/version.php') &&
$dbman->table_exists($enrolauthorize) &&
$dbman->table_exists($enrolauthorizerefunds)) {
$enrolauthorizecount = $DB->count_records('enrol_authorize');
$enrolauthorizerefundcount = $DB->count_records('enrol_authorize_refunds');
if (empty($enrolauthorizecount) && empty($enrolauthorizerefundcount)) {
// Drop the database tables.
$dbman->drop_table($enrolauthorize);
$dbman->drop_table($enrolauthorizerefunds);
// Drop the message provider and associated data manually.
$DB->delete_records('message_providers', array('component' => 'enrol_authorize'));
$DB->delete_records_select('config_plugins', "plugin = 'message' AND ".$DB->sql_like('name', '?', false), array("%_provider_enrol_authorize_%"));
$DB->delete_records_select('user_preferences', $DB->sql_like('name', '?', false), array("message_provider_enrol_authorize_%"));
// Remove capabilities.
capabilities_cleanup('enrol_authorize');
// Remove all other associated config.
unset_all_config_for_plugin('enrol_authorize');
}
}
upgrade_main_savepoint(true, 2013071500.01);
}
return true; return true;
} }

View file

@ -1468,6 +1468,7 @@ function unset_config($name, $plugin=NULL) {
/** /**
* Remove all the config variables for a given plugin. * Remove all the config variables for a given plugin.
* NOTE: this function is called from lib/db/upgrade.php
* *
* @param string $plugin a plugin, for example 'quiz' or 'qtype_multichoice'; * @param string $plugin a plugin, for example 'quiz' or 'qtype_multichoice';
* @return boolean whether the operation succeeded. * @return boolean whether the operation succeeded.

View file

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$version = 2013071500.00; // YYYYMMDD = weekly release date of this DEV branch $version = 2013071500.01; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches // RR = release increments - 00 in DEV branches
// .XX = incremental changes // .XX = incremental changes