Commit 98a31d10ef589a85155181576f5d3587d09fbf59

Authored by megan_w
1 parent 1a2abfaa

Merged in from trunk...

KTS-3335
"KTPluginRegistry MUST respect the plugins order when registering plugins"
Fixed. Plugins are now registered in the order they're loaded. Put the registration into a transaction.

Committed by: Megan Watson
Reviewed by: Jonathan Byrne




git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.5.2c-Release-Branch@8521 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/plugins/pluginregistry.inc.php
... ... @@ -85,9 +85,16 @@ class KTPluginRegistry {
85 85 function &getPlugins() {
86 86 $aRet = array();
87 87 foreach (array_keys($this->_aPluginDetails) as $sPluginName) {
88   - $aRet[] =& $this->getPlugin($sPluginName);
  88 + $oPlugin =& $this->getPlugin($sPluginName);
  89 + $aRet[(int)$oPlugin->iOrder][] =& $oPlugin;
89 90 }
90   - return $aRet;
  91 + ksort($aRet);
  92 + $aRes = array();
  93 + foreach($aRet as $iOrder => $aPlugins) {
  94 + foreach(array_keys($aPlugins) as $iPlugin) {
  95 + $aRes[] =& $aRet[$iOrder][$iPlugin];
  96 + }
  97 + }
  98 + return $aRes;
91 99 }
92   -}
93   -
  100 +}
94 101 \ No newline at end of file
... ...
lib/plugins/pluginutil.inc.php
... ... @@ -180,7 +180,9 @@ class KTPluginUtil {
180 180  
181 181 // Check that there are plugins and if not, register them
182 182 if (empty($aPluginHelpers)) {
  183 + DBUtil::startTransaction();
183 184 KTPluginUtil::registerPlugins();
  185 + DBUtil::commit();
184 186  
185 187 $query = "SELECT h.classname, h.pathname, h.plugin FROM plugin_helper h
186 188 INNER JOIN plugins p ON (p.namespace = h.plugin)
... ... @@ -483,7 +485,8 @@ class KTPluginUtil {
483 485 }
484 486 }
485 487 $oRegistry =& KTPluginRegistry::getSingleton();
486   - foreach ($oRegistry->getPlugins() as $oPlugin) {
  488 + $aRegistryList = $oRegistry->getPlugins();
  489 + foreach ($aRegistryList as $oPlugin) {
487 490 $res = $oPlugin->register();
488 491 if (PEAR::isError($res)) {
489 492 var_dump($res);
... ...