Skip to content

Commit

Permalink
refs #4357 post event only to activated and loaded plugins. Usually a…
Browse files Browse the repository at this point in the history
…n activated plugin should be loaded anyway, but this seems not to be the case in tests where plugins are sometimes manually unloaded. Another solution would be to remove the plugin from activated plugins list ($pluginsToLoad) when unloadPlugin() is called. Not sure about side effects
  • Loading branch information
tsteur committed Dec 3, 2013
1 parent 77ea235 commit 04326ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/EventDispatcher.php
Expand Up @@ -66,7 +66,7 @@ public function postEvent($eventName, $params, $pending = false, $plugins = null
}

if (empty($plugins)) {
$plugins = \Piwik\Plugin\Manager::getInstance()->getActivatedPlugins();
$plugins = \Piwik\Plugin\Manager::getInstance()->getActivatedAndLoadedPlugins();
}

$callbacks = array();
Expand Down
16 changes: 13 additions & 3 deletions core/Plugin/Manager.php
Expand Up @@ -566,7 +566,7 @@ public function getLoadedPlugins()
}

/**
* Returns a list of all names of currently activated plugin eg,
* Returns a list of all names of currently activated and loaded plugin eg,
*
* array(
* 'UserCountry'
Expand All @@ -575,9 +575,19 @@ public function getLoadedPlugins()
*
* @return string[]
*/
public function getActivatedPlugins()
public function getActivatedAndLoadedPlugins()
{
return $this->pluginsToLoad;
$activatedPlugins = $this->pluginsToLoad;
$loadedPlugins = $this->loadedPlugins;

$plugins = array();
foreach ($activatedPlugins as $activatedPlugin) {
if (array_key_exists($activatedPlugin, $loadedPlugins)) {
$plugins[] = $activatedPlugin;
}
}

return $plugins;
}

/**
Expand Down

0 comments on commit 04326ba

Please sign in to comment.