From 450d20e46c330cf2fc63f3b13a60992661acc894 Mon Sep 17 00:00:00 2001 From: donald_jackson Date: Thu, 4 Dec 2008 13:33:58 +0000 Subject: [PATCH] "Fatal error after having updated and reread the plugins a few times on Windows XP and Windows Vista." KTC-649 Implemented basic priority mechanism to force load of ktcore, ktstandard and i18n plugins before others. --- lib/plugins/pluginutil.inc.php | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/plugins/pluginutil.inc.php b/lib/plugins/pluginutil.inc.php index 40b95a6..7d6d66b 100644 --- a/lib/plugins/pluginutil.inc.php +++ b/lib/plugins/pluginutil.inc.php @@ -525,6 +525,22 @@ class KTPluginUtil { } return false; } + + /* Get the priority of the plugin */ + function getPluginPriority($sFile) { + $defaultPriority = 10; + $priority = array( + "ktcore" => 1, + "ktstandard" => 2, + "i18n" => 3 + ); + foreach($priority as $pattern => $priority) { + if(ereg($pattern, $sFile)) { + return $priority; + } + } + return $defaultPriority; + } /** * Read the plugins directory and register all plugins in the database. @@ -539,17 +555,31 @@ class KTPluginUtil { $oCache->deleteAllCaches(); // Remove all entries from the plugin_helper table and refresh it. - $query = "DELETE FROM plugin_helper"; + $query = "TRUNCATE plugin_helper"; DBUtil::runQuery($query); $files = array(); + $plugins = array(); + KTPluginUtil::_walk(KT_DIR . '/plugins', $files); foreach ($files as $sFile) { $plugin_ending = "Plugin.php"; if (substr($sFile, -strlen($plugin_ending)) === $plugin_ending) { - require_once($sFile); + /* Set default priority */ + $plugins[$sFile] = KTPluginUtil::getPluginPriority($sFile); } } + + /* Sort the plugins by priority */ + asort($plugins); + + foreach($plugins as $sFile => $priority) { + require_once($sFile); + } + + + + $oRegistry =& KTPluginRegistry::getSingleton(); $aRegistryList = $oRegistry->getPlugins(); -- libgit2 0.21.4