Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore plugin timings when matomo is not installed yet #16744

Merged
merged 1 commit into from Nov 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 14 additions & 10 deletions core/Plugin/Manager.php
Expand Up @@ -527,7 +527,8 @@ public function deactivatePlugin($pluginName)

// execute deactivate() to let the plugin do cleanups
$this->executePluginDeactivate($pluginName);
$this->savePluginDeactivationTime($pluginName);

$this->savePluginTime(self::LAST_PLUGIN_DEACTIVATION_TIME_OPTION_PREFIX, $pluginName);

$this->unloadPluginFromMemory($pluginName);

Expand Down Expand Up @@ -692,7 +693,7 @@ public function activatePlugin($pluginName)
$this->installPluginIfNecessary($plugin);
$plugin->activate();

$this->savePluginActivationTime($pluginName);
$this->savePluginTime(self::LAST_PLUGIN_ACTIVATION_TIME_OPTION_PREFIX, $pluginName);

EventDispatcher::getInstance()->postPendingEventsTo($plugin);

Expand Down Expand Up @@ -1669,16 +1670,19 @@ public function loadPluginTranslations()
}
}

private function savePluginActivationTime($pluginName)
private function savePluginTime($timingName, $pluginName)
{
$optionName = self::LAST_PLUGIN_ACTIVATION_TIME_OPTION_PREFIX . $pluginName;
Option::set($optionName, time());
}
$optionName = $timingName . $pluginName;

private function savePluginDeactivationTime($pluginName)
{
$optionName = self::LAST_PLUGIN_DEACTIVATION_TIME_OPTION_PREFIX . $pluginName;
Option::set($optionName, time());
try {
Option::set($optionName, time());
} catch (\Exception $e) {
if (SettingsPiwik::isMatomoInstalled()) {
throw $e;
}
// we ignore any error while Matomo is not installed yet. refs #16741
}
}

}