From: Adrian Greeve Date: Fri, 11 Sep 2015 06:00:37 +0000 (+0800) Subject: Script for downgrading moodle version numbers X-Git-Tag: v1.5.2~5 X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=9fc5f68720ccc9677910d298341eb1c50f79745c;p=mdk.git Script for downgrading moodle version numbers This will check to see if the main version number and any plugins have a status of downgraded (The version number in the database is higher than the new one). Then it will change the version numbers in the config_plugin table. --- diff --git a/mdk/scripts/version.php b/mdk/scripts/version.php new file mode 100644 index 0000000..f26e326 --- /dev/null +++ b/mdk/scripts/version.php @@ -0,0 +1,45 @@ +libdir.'/clilib.php'); +require("$CFG->dirroot/version.php"); + +// Purge caches to ensure that all version information is up-to-date. +purge_all_caches(); + +cli_separator(); +cli_heading('Update all version numbers'); + +$possiblecandidates = array(); + +// Check that the main version hasn't changed. +$versiondifference = false; +if ((float)$CFG->version !== $version) { + $versiondifference = true; +} + +$pluginmanager = core_plugin_manager::instance(); +$plugininfo = $pluginmanager->get_plugins(); +foreach ($plugininfo as $plugins) { + foreach ($plugins as $key => $plugin) { + $statuscode = $plugin->get_status(); + if ($statuscode == "downgrade") { + $possiblecandidates[] = $plugin; + } + } +} + +// Fix everything. +if ($versiondifference) { + set_config('version', $version); + mtrace('Main version updated'); +} +if (!empty($possiblecandidates)) { + + foreach ($possiblecandidates as $plugin) { + $name = $plugin->type . '_' . $plugin->name; + set_config('version', $plugin->versiondisk, $name); + mtrace($plugin->displayname . ' updated.'); + } +}