diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-09-17 17:12:09 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-09-17 17:12:09 +0000 |
commit | a5c81f0ce1b2399314b516229da00dc51075003c (patch) | |
tree | 789deeb2ec02b86b5833be6692f356982fa8b12f /engine/lib/plugins.php | |
parent | a4a8218cedc9bc776be13cdbb302319b8e82653e (diff) | |
download | elgg-a5c81f0ce1b2399314b516229da00dc51075003c.tar.gz elgg-a5c81f0ce1b2399314b516229da00dc51075003c.tar.bz2 |
Optimised plugin query.
git-svn-id: https://code.elgg.org/elgg/trunk@2095 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/plugins.php')
-rw-r--r-- | engine/lib/plugins.php | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index c71495c40..6ef8f5779 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -11,7 +11,10 @@ * @copyright Curverider Ltd 2008
* @link http://elgg.org/
*/
-
+ + + /// Cache enabled plugins per page + $ENABLED_PLUGINS_CACHE = NULL;
/** * PluginException @@ -445,22 +448,23 @@ */ function is_plugin_enabled($plugin, $site_guid = 0) { - //return execute_privileged_codeblock('__is_plugin_enabled_priv', array('plugin'=>$plugin, 'site_guid' => $site_guid)); - // Does this need to be in privileged? Doesn't seem to... - - global $CONFIG; + global $CONFIG, $ENABLED_PLUGINS_CACHE; $site_guid = (int) $site_guid; if ($site_guid == 0) $site_guid = $CONFIG->site_guid; - $site = get_entity($site_guid); - if (!($site instanceof ElggSite)) - throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $site_guid, "ElggSite")); - $enabled = find_metadata("enabled_plugins", $plugin, "site", "", 10, 0, "", $site_guid); - if ($enabled) - return true; + if (!$ENABLED_PLUGINS_CACHE) { + $site = get_entity($site_guid); + if (!($site instanceof ElggSite)) + throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $site_guid, "ElggSite")); + + $ENABLED_PLUGINS_CACHE = $site->enabled_plugins; + } + + foreach ($ENABLED_PLUGINS_CACHE as $e) + if ($e == $plugin) return true; return false; } |