MDL-52777 tool_usertours: Only check plugin for needs update

The moodle_needs_upgrade() function includes every version.php in Moodle
which poses a performance issue, especially when called on every page.
This commit is contained in:
Andrew Nicols 2016-10-20 11:16:52 +08:00
parent a8dded9bfc
commit c4d5fb53ce

View File

@ -561,8 +561,8 @@ class manager {
public static function get_matching_tours(\moodle_url $pageurl) {
global $DB, $PAGE;
// Do not show tours whilst upgrades are pending.
if (moodle_needs_upgrading()) {
if (self::tour_upgrade_pending()) {
// Do not show tours whilst upgrades are pending agains the plugin.
return null;
}
@ -587,6 +587,21 @@ EOF;
return null;
}
/**
* Determine whether the tour plugin is pending an upgrade.
*
* @return bool
*/
public static function tour_upgrade_pending() {
$plugin = new \stdClass();
include(dirname(__DIR__) . '/version.php');
$manager = \core_plugin_manager::instance();
$plugininfo = $manager->get_plugin_info('tool_usertours');
return ($plugin->version != $plugininfo->versiondb);
}
/**
* Import the provided tour JSON.
*