From 1d6eba632ff0412d12d4de83f4f369377a17d6c2 Mon Sep 17 00:00:00 2001 From: Thomas Steur <tsteur@users.noreply.github.com> Date: Sat, 13 May 2017 10:37:40 +1200 Subject: [PATCH] Unload plugin instead of deactivating it when a plugin has a missing dependency (#11682) Deactivating a plugin in case of a missing dependency is a bit risky. If just once a dependency is missing it would be directly deactivated. For example during an update we may run into an issue where a plugin dependency might be missing just for a short time frame. There may be also other edge cases where this might be the case. It would be better to instead trigger a notification only. I would show this notification only to super users but we do not have anything loaded at this time. Any other ideas? --- core/Plugin/Manager.php | 6 +++--- plugins/CorePluginsAdmin/lang/en.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index 60fd9aa9bb..9466304e27 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -868,17 +868,17 @@ class Manager } if ($newPlugin->hasMissingDependencies()) { - $this->deactivatePlugin($pluginName); + $this->unloadPluginFromMemory($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 = Piwik::translate('CorePluginsAdmin_WeCouldNotLoadThePluginAsItHasMissingDependencies', 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); + Notification\Manager::notify('PluginManager_PluginUnloaded', $notification); return $pluginsToPostPendingEventsTo; } diff --git a/plugins/CorePluginsAdmin/lang/en.json b/plugins/CorePluginsAdmin/lang/en.json index 0da98b6179..289c2ef46c 100644 --- a/plugins/CorePluginsAdmin/lang/en.json +++ b/plugins/CorePluginsAdmin/lang/en.json @@ -63,7 +63,7 @@ "UninstallConfirm": "You are about to uninstall a plugin %s. The plugin will be completely removed from your platform and it won't be recoverable. Are you sure you want to do this?", "Version": "Version", "ViewAllMarketplacePlugins": "View all Marketplace plugins", - "WeDeactivatedThePluginAsItHasMissingDependencies": "We disabled the plugin %s as it has missing dependencies:", + "WeCouldNotLoadThePluginAsItHasMissingDependencies": "The plugin %s could not be loaded as it has missing dependencies: %s", "Websites": "Websites" } } -- GitLab