mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-34401 Add caching into get_plugin_types() function
This is a simple MUC replacement for the previous static arrays.
This commit is contained in:
parent
dbaaeb935d
commit
07622d7dfa
@ -114,6 +114,18 @@ $definitions = array(
|
||||
'persistent' => true,
|
||||
),
|
||||
|
||||
// Cache for the list of known plugin and subplugin types - {@see get_plugin_types()}.
|
||||
// Contains two arrays of (string)pluginname => (string)location. The first array with
|
||||
// the key 0 contains locations relative to $CFG->dirroot. The second array with the
|
||||
// key 1 contains absolute paths.
|
||||
'plugintypes' => array(
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'simplekeys' => true, // 0 or 1 depending on the requested location type.
|
||||
'simpledata' => true, // Array of strings.
|
||||
'persistent' => true, // Likely there will be a couple of calls to this.
|
||||
'persistmaxsize' => 2, // Both arrays should stay loaded in memory.
|
||||
),
|
||||
|
||||
// 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.
|
||||
|
@ -8183,10 +8183,18 @@ function get_core_subsystems() {
|
||||
function get_plugin_types($fullpaths=true) {
|
||||
global $CFG;
|
||||
|
||||
static $info = null;
|
||||
static $fullinfo = null;
|
||||
$cache = cache::make('core', 'plugintypes');
|
||||
|
||||
if (!$info) {
|
||||
if ($fullpaths) {
|
||||
$cached = $cache->get(1);
|
||||
} else {
|
||||
$cached = $cache->get(0);
|
||||
}
|
||||
|
||||
if ($cached !== false) {
|
||||
return $cached;
|
||||
|
||||
} else {
|
||||
$info = array('qtype' => 'question/type',
|
||||
'mod' => 'mod',
|
||||
'auth' => 'auth',
|
||||
@ -8235,9 +8243,12 @@ function get_plugin_types($fullpaths=true) {
|
||||
foreach ($info as $type => $dir) {
|
||||
$fullinfo[$type] = $CFG->dirroot.'/'.$dir;
|
||||
}
|
||||
}
|
||||
|
||||
return ($fullpaths ? $fullinfo : $info);
|
||||
$cache->set(0, $info);
|
||||
$cache->set(1, $fullinfo);
|
||||
|
||||
return ($fullpaths ? $fullinfo : $info);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -9130,6 +9141,7 @@ function moodle_needs_upgrading() {
|
||||
|
||||
// We have to purge plugin related caches now to be sure we have fresh data
|
||||
// and new plugins can be detected.
|
||||
cache::make('core', 'plugintypes')->purge();
|
||||
cache::make('core', 'pluginlist')->purge();
|
||||
|
||||
// Check the main version first.
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2013030800.01; // YYYYMMDD = weekly release date of this DEV branch
|
||||
$version = 2013030800.02; // 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