mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 16:04:25 +02:00
MDL-34401 Add caching into get_plugin_list() function
This is quite frequently called function at most pages. The cache needs to be invalidated only when a new plugin is installed or existing plugin uninstalled. However, given how moodle_needs_upgrading() checks for new plugins, we need to purge the cache there. Which is a shame because this means that the cache gets purged in each cron call and when the admin looks at the front page and/or system notifications page.
This commit is contained in:
parent
8673a98d1d
commit
dbaaeb935d
@ -105,11 +105,23 @@ $definitions = array(
|
||||
'persistent' => true, // Likely there will be a couple of calls to this.
|
||||
'persistmaxsize' => 2, // The original cache used 1, we've increased that to two.
|
||||
),
|
||||
// Used to cache calendar subscriptions.
|
||||
|
||||
// Used to cache calendar subscriptions.
|
||||
'calendar_subscriptions' => array(
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'simplekeys' => true,
|
||||
'simpledata' => true,
|
||||
'persistent' => true,
|
||||
)
|
||||
),
|
||||
|
||||
// Cache for the list of installed plugins - {@see get_plugin_list()}.
|
||||
// The key consists of the plugin type string (e.g. mod, block, enrol etc).
|
||||
// The value is an associative array of plugin name => plugin location.
|
||||
'pluginlist' => array(
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'simplekeys' => true,
|
||||
'simpledata' => true,
|
||||
'persistent' => true,
|
||||
'persistentmaxsize' => 2,
|
||||
),
|
||||
);
|
||||
|
@ -8248,6 +8248,12 @@ function get_plugin_types($fullpaths=true) {
|
||||
function get_plugin_list($plugintype) {
|
||||
global $CFG;
|
||||
|
||||
$cache = cache::make('core', 'pluginlist');
|
||||
$cached = $cache->get($plugintype);
|
||||
if ($cached !== false) {
|
||||
return $cached;
|
||||
}
|
||||
|
||||
$ignored = array('CVS', '_vti_cnf', 'simpletest', 'db', 'yui', 'tests');
|
||||
if ($plugintype == 'auth') {
|
||||
// Historically we have had an auth plugin called 'db', so allow a special case.
|
||||
@ -8281,10 +8287,12 @@ function get_plugin_list($plugintype) {
|
||||
} else {
|
||||
$types = get_plugin_types(true);
|
||||
if (!array_key_exists($plugintype, $types)) {
|
||||
$cache->set($plugintype, array());
|
||||
return array();
|
||||
}
|
||||
$fulldir = $types[$plugintype];
|
||||
if (!file_exists($fulldir)) {
|
||||
$cache->set($plugintype, array());
|
||||
return array();
|
||||
}
|
||||
$fulldirs[] = $fulldir;
|
||||
@ -8317,6 +8325,7 @@ function get_plugin_list($plugintype) {
|
||||
|
||||
//TODO: implement better sorting once we migrated all plugin names to 'pluginname', ksort does not work for unicode, that is why we have to sort by the dir name, not the strings!
|
||||
ksort($result);
|
||||
$cache->set($plugintype, $result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -9119,7 +9128,11 @@ function moodle_needs_upgrading() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// main versio nfirst
|
||||
// We have to purge plugin related caches now to be sure we have fresh data
|
||||
// and new plugins can be detected.
|
||||
cache::make('core', 'pluginlist')->purge();
|
||||
|
||||
// Check the main version first.
|
||||
$version = null;
|
||||
include($CFG->dirroot.'/version.php'); // defines $version and upgrades
|
||||
if ($version > $CFG->version) {
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2013030800.00; // YYYYMMDD = weekly release date of this DEV branch
|
||||
$version = 2013030800.01; // YYYYMMDD = weekly release date of this DEV branch
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user