aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/admin/plugins/disable.php5
-rw-r--r--actions/admin/plugins/disableall.php5
-rw-r--r--actions/admin/plugins/enable.php7
-rw-r--r--actions/admin/plugins/enableall.php7
-rw-r--r--actions/admin/plugins/reorder.php5
-rw-r--r--engine/lib/elgglib.php15
-rw-r--r--engine/lib/plugins.php49
-rw-r--r--upgrade.php5
8 files changed, 77 insertions, 21 deletions
diff --git a/actions/admin/plugins/disable.php b/actions/admin/plugins/disable.php
index cbe75a665..32ae451a7 100644
--- a/actions/admin/plugins/disable.php
+++ b/actions/admin/plugins/disable.php
@@ -32,7 +32,10 @@
register_error(sprintf(elgg_echo('admin:plugins:disable:no'), $p));
}
- elgg_view_regenerate_simplecache();
+ elgg_view_regenerate_simplecache();
+
+ $cache = elgg_get_filepath_cache();
+ $cache->delete('view_paths');
forward($_SERVER['HTTP_REFERER']);
exit;
diff --git a/actions/admin/plugins/disableall.php b/actions/admin/plugins/disableall.php
index efb91f773..a01b74fa5 100644
--- a/actions/admin/plugins/disableall.php
+++ b/actions/admin/plugins/disableall.php
@@ -29,7 +29,10 @@
register_error(sprintf(elgg_echo('admin:plugins:disable:no'), $p));
}
- elgg_view_regenerate_simplecache();
+ elgg_view_regenerate_simplecache();
+
+ $cache = elgg_get_filepath_cache();
+ $cache->delete('view_paths');
forward($_SERVER['HTTP_REFERER']);
exit;
diff --git a/actions/admin/plugins/enable.php b/actions/admin/plugins/enable.php
index 072924eec..d81ab0551 100644
--- a/actions/admin/plugins/enable.php
+++ b/actions/admin/plugins/enable.php
@@ -32,8 +32,11 @@
register_error(sprintf(elgg_echo('admin:plugins:enable:no'), $p));
}
- elgg_view_regenerate_simplecache();
-
+ elgg_view_regenerate_simplecache();
+
+ $cache = elgg_get_filepath_cache();
+ $cache->delete('view_paths');
+
forward($_SERVER['HTTP_REFERER']);
exit;
?> \ No newline at end of file
diff --git a/actions/admin/plugins/enableall.php b/actions/admin/plugins/enableall.php
index 5e0d8c3b5..f31b4593d 100644
--- a/actions/admin/plugins/enableall.php
+++ b/actions/admin/plugins/enableall.php
@@ -11,7 +11,7 @@
*/
require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php");
-
+
// block non-admin users
admin_gatekeeper();
@@ -29,7 +29,12 @@
register_error(sprintf(elgg_echo('admin:plugins:enable:no'), $p));
}
+ // Regen view cache
elgg_view_regenerate_simplecache();
+
+ // Regen paths cache
+ $cache = elgg_get_filepath_cache();
+ $cache->delete('view_paths');
forward($_SERVER['HTTP_REFERER']);
exit;
diff --git a/actions/admin/plugins/reorder.php b/actions/admin/plugins/reorder.php
index be5981394..0e328f54d 100644
--- a/actions/admin/plugins/reorder.php
+++ b/actions/admin/plugins/reorder.php
@@ -46,7 +46,10 @@
else
register_error(sprintf(elgg_echo('admin:plugins:reorder:no'), $plugin));
- elgg_view_regenerate_simplecache();
+ elgg_view_regenerate_simplecache();
+
+ $cache = elgg_get_filepath_cache();
+ $cache->delete('view_paths');
forward($_SERVER['HTTP_REFERER']);
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 1b2629a22..5571339cd 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -496,6 +496,21 @@
}
/**
+ * This is a factory function which produces an ElggCache object suitable for caching file load paths.
+ *
+ * TODO: Can this be done in a cleaner way?
+ * TODO: Swap to memcache etc?
+ */
+ function elgg_get_filepath_cache()
+ {
+ global $CONFIG;
+ static $FILE_PATH_CACHE;
+ if (!$FILE_PATH_CACHE) $FILE_PATH_CACHE = new ElggFileCache($CONFIG->dataroot);
+
+ return $FILE_PATH_CACHE;
+ }
+
+ /**
* Internal function for retrieving views used by elgg_view_tree
*
* @param unknown_type $dir
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index 937766e66..c70cd8ebc 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -210,10 +210,21 @@
* @package Elgg
* @subpackage Core
*/
- function load_plugins() {
-
- global $CONFIG;
- if (!empty($CONFIG->pluginspath)) {
+ function load_plugins() {
+
+ global $CONFIG;
+
+ $cache = elgg_get_filepath_cache();
+
+ if (!empty($CONFIG->pluginspath)) {
+
+ // See if we have cached values for things
+ $cached_view_paths = $cache->load('view_paths');
+ if ($cached_view_paths) $CONFIG->views = unserialize($cached_view_paths);
+
+ $cached_lang_paths = $cache->load('lang_paths');
+ if ($cached_lang_paths) $CONFIG->views = unserialize($cached_lang_paths);
+
// temporary disable all plugins if there is a file called 'disabled' in the plugin dir
if (file_exists($CONFIG->pluginspath . "disabled"))
@@ -221,28 +232,38 @@
$plugins = get_plugin_list();
- if (sizeof($plugins))
+ if (sizeof($plugins))
+ {
foreach($plugins as $mod) {
if (is_plugin_enabled($mod)) {
if (file_exists($CONFIG->pluginspath . $mod)) {
if (!include($CONFIG->pluginspath . $mod . "/start.php"))
- throw new PluginException(sprintf(elgg_echo('PluginException:MisconfiguredPlugin'), $mod));
- if (is_dir($CONFIG->pluginspath . $mod . "/views")) {
- if ($handle = opendir($CONFIG->pluginspath . $mod . "/views")) {
- while ($viewtype = readdir($handle)) {
- if (!in_array($viewtype,array('.','..','.svn','CVS')) && is_dir($CONFIG->pluginspath . $mod . "/views/" . $viewtype)) {
- autoregister_views("",$CONFIG->pluginspath . $mod . "/views/" . $viewtype,$CONFIG->pluginspath . $mod . "/views/", $viewtype);
+ throw new PluginException(sprintf(elgg_echo('PluginException:MisconfiguredPlugin'), $mod));
+
+ if (!$cached_view_paths)
+ {
+ if (is_dir($CONFIG->pluginspath . $mod . "/views")) {
+ if ($handle = opendir($CONFIG->pluginspath . $mod . "/views")) {
+ while ($viewtype = readdir($handle)) {
+ if (!in_array($viewtype,array('.','..','.svn','CVS')) && is_dir($CONFIG->pluginspath . $mod . "/views/" . $viewtype)) {
+ autoregister_views("",$CONFIG->pluginspath . $mod . "/views/" . $viewtype,$CONFIG->pluginspath . $mod . "/views/", $viewtype);
+ }
}
}
- }
- }
+ }
+ }
+
if (is_dir($CONFIG->pluginspath . $mod . "/languages")) {
register_translations($CONFIG->pluginspath . $mod . "/languages/");
}
}
}
}
-
+ }
+
+ // Cache results
+ if (!$cached_view_paths)
+ $cache->save('view_paths', serialize($CONFIG->views));
}
}
diff --git a/upgrade.php b/upgrade.php
index 90207f880..631ab1c67 100644
--- a/upgrade.php
+++ b/upgrade.php
@@ -22,7 +22,10 @@
if (version_upgrade_check()) {
version_upgrade();
}
- datalist_set('simplecache_lastupdate',0);
+ datalist_set('simplecache_lastupdate',0);
+
+ $cache = elgg_get_filepath_cache();
+ $cache->delete('view_paths');
} else {
global $CONFIG;
echo elgg_view('settings/upgrading');