Skip to content
Extraits de code Groupes Projets
Valider c7a9367d rédigé par Thomas Steur's avatar Thomas Steur Validation de GitHub
Parcourir les fichiers

Merge pull request #11678 from piwik/requiredplugins_faster

Make sure required plugins are loaded in correct order
parents 125d502d 3d9c7766
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -15,7 +15,6 @@ use Piwik\Columns\Dimension;
use Piwik\Config;
use Piwik\Config as PiwikConfig;
use Piwik\Container\StaticContainer;
use Piwik\Db;
use Piwik\EventDispatcher;
use Piwik\Exception\PluginDeactivatedException;
use Piwik\Filesystem;
......@@ -26,10 +25,8 @@ use Piwik\Plugin;
use Piwik\Plugin\Dimension\ActionDimension;
use Piwik\Plugin\Dimension\ConversionDimension;
use Piwik\Plugin\Dimension\VisitDimension;
use Piwik\Session;
use Piwik\Settings\Storage as SettingsStorage;
use Piwik\Theme;
use Piwik\Tracker;
use Piwik\Translation\Translator;
use Piwik\Updater;
......@@ -838,37 +835,56 @@ class Manager
{
$pluginsToPostPendingEventsTo = array();
foreach ($this->pluginsToLoad as $pluginName) {
if (!$this->isPluginLoaded($pluginName)
&& !$this->isPluginThirdPartyAndBogus($pluginName)
) {
$newPlugin = $this->loadPlugin($pluginName);
if ($newPlugin === null) {
continue;
}
$pluginsToPostPendingEventsTo = $this->reloadActivatedPlugin($pluginName, $pluginsToPostPendingEventsTo);
}
if ($newPlugin->hasMissingDependencies()) {
$this->deactivatePlugin($pluginName);
// post pending events after all plugins are successfully loaded
foreach ($pluginsToPostPendingEventsTo as $plugin) {
EventDispatcher::getInstance()->postPendingEventsTo($plugin);
}
}
// at this state we do not know yet whether current user has super user access. We do not even know
// if someone is actually logged in.
$message = Piwik::translate('CorePluginsAdmin_WeDeactivatedThePluginAsItHasMissingDependencies', array($pluginName, $newPlugin->getMissingDependenciesAsString()));
$message .= ' ';
$message .= Piwik::translate('General_PleaseContactYourPiwikAdministrator');
private function reloadActivatedPlugin($pluginName, $pluginsToPostPendingEventsTo)
{
if ($this->isPluginLoaded($pluginName) || $this->isPluginThirdPartyAndBogus($pluginName)) {
return $pluginsToPostPendingEventsTo;
}
$notification = new Notification($message);
$notification->context = Notification::CONTEXT_ERROR;
Notification\Manager::notify('PluginManager_PluginDeactivated', $notification);
continue;
}
$newPlugin = $this->loadPlugin($pluginName);
$pluginsToPostPendingEventsTo[] = $newPlugin;
if ($newPlugin === null) {
return $pluginsToPostPendingEventsTo;
}
$requirements = $newPlugin->getMissingDependencies();
if (!empty($requirements)) {
foreach ($requirements as $requirement) {
$possiblePluginName = $requirement['requirement'];
if (in_array($possiblePluginName, $this->pluginsToLoad, $strict = true)) {
$pluginsToPostPendingEventsTo = $this->reloadActivatedPlugin($possiblePluginName, $pluginsToPostPendingEventsTo);
}
}
}
// post pending events after all plugins are successfully loaded
foreach ($pluginsToPostPendingEventsTo as $plugin) {
EventDispatcher::getInstance()->postPendingEventsTo($plugin);
if ($newPlugin->hasMissingDependencies()) {
$this->deactivatePlugin($pluginName);
// at this state we do not know yet whether current user has super user access. We do not even know
// if someone is actually logged in.
$message = Piwik::translate('CorePluginsAdmin_WeDeactivatedThePluginAsItHasMissingDependencies', array($pluginName, $newPlugin->getMissingDependenciesAsString()));
$message .= ' ';
$message .= Piwik::translate('General_PleaseContactYourPiwikAdministrator');
$notification = new Notification($message);
$notification->context = Notification::CONTEXT_ERROR;
Notification\Manager::notify('PluginManager_PluginDeactivated', $notification);
return $pluginsToPostPendingEventsTo;
}
$pluginsToPostPendingEventsTo[] = $newPlugin;
return $pluginsToPostPendingEventsTo;
}
public function getIgnoredBogusPlugins()
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter