MDL-32265 moodlelib: Improved performance of moodle_needs_upgrading

This commit is contained in:
Sam Hemelryk 2012-03-30 09:43:51 +13:00
parent a280078197
commit dd57a4de08

View File

@ -8601,8 +8601,7 @@ function check_gd_version() {
* Checks version numbers of main code and all modules to see
* if there are any mismatches
*
* @global object
* @global object
* @global moodle_database $DB
* @return bool
*/
function moodle_needs_upgrading() {
@ -8665,6 +8664,8 @@ function moodle_needs_upgrading() {
$plugintypes = get_plugin_types();
unset($plugintypes['mod']);
unset($plugintypes['block']);
$versions = $DB->get_records_menu('config_plugins', array('name' => 'version'), 'plugin', 'plugin, value');
foreach ($plugintypes as $type=>$unused) {
$plugs = get_plugin_list($type);
foreach ($plugs as $plug=>$fullplug) {
@ -8674,7 +8675,11 @@ function moodle_needs_upgrading() {
}
$plugin = new stdClass();
include($fullplug.'/version.php'); // defines $plugin with version etc
$installedversion = get_config($component, 'version');
if (array_key_exists($component, $versions)) {
$installedversion = $versions[$component];
} else {
$installedversion = get_config($component, 'version');
}
if (empty($installedversion)) { // new installation
return true;
} else if ($installedversion < $plugin->version) { // upgrade