Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Config.php36
-rw-r--r--core/Config/Compat.php35
-rw-r--r--core/Piwik.php3
-rw-r--r--core/PluginsManager.php20
-rw-r--r--core/Updates/0.5.4.php16
-rw-r--r--core/Updates/0.6.3.php8
-rw-r--r--plugins/CoreAdminHome/Controller.php2
-rw-r--r--plugins/Login/Controller.php1
-rw-r--r--plugins/PrivacyManager/Controller.php270
-rw-r--r--plugins/UsersManager/Controller.php6
-rw-r--r--tests/core/Config.test.php8
11 files changed, 207 insertions, 198 deletions
diff --git a/core/Config.php b/core/Config.php
index b6d440b99f..e7879d5a77 100644
--- a/core/Config.php
+++ b/core/Config.php
@@ -394,31 +394,34 @@ class Piwik_Config
}
}
- $sections = array_unique(array_merge(array_keys($configGlobal), array_keys($configCache)));
- foreach($sections as $section)
+ $sectionNames = array_unique(array_merge(array_keys($configGlobal), array_keys($configCache)));
+
+ foreach($sectionNames as $section)
{
if(!isset($configCache[$section]))
{
continue;
}
- $configLocal = $configCache[$section];
- // Only merge if the section exists in Global.ini.php (in case a section only lives in config.ini.php)
- if(isset($configGlobal[$section]))
- {
- $configLocal = $this->array_unmerge($configGlobal[$section], $configCache[$section]);
- }
+ // Only merge if the section exists in global.ini.php (in case a section only lives in config.ini.php)
+ $config = isset($configGlobal[$section])
+ ? $this->array_unmerge($configGlobal[$section], $configCache[$section])
+ : $configCache[$section];
- if (count($configLocal) == 0)
+ if (count($config) == 0)
{
continue;
}
- $dirty = true;
+ if (!isset($configLocal[$section])
+ || self::compareElements($config, $configLocal[$section]))
+ {
+ $dirty = true;
+ }
$output .= "[$section]\n";
- foreach($configLocal as $name => $value)
+ foreach($config as $name => $value)
{
$value = $this->encodeValues($value);
@@ -444,6 +447,7 @@ class Piwik_Config
$output .= $name.' = '.$value."\n";
}
}
+
$output .= "\n";
}
@@ -475,7 +479,7 @@ class Piwik_Config
$output = $this->dumpConfig($configLocal, $configGlobal, $configCache);
if ($output !== false)
{
- @file_put_contents($pathLocal, $output );
+ @file_put_contents($pathLocal, $output);
}
$this->clear();
@@ -488,12 +492,4 @@ class Piwik_Config
{
$this->writeConfig($this->configLocal, $this->configGlobal, $this->configCache, $this->pathLocal);
}
-
- /**
- * At the script shutdown, we save the new configuration file, if the user has set some values
- */
- public function __destruct()
- {
- $this->forceSave();
- }
}
diff --git a/core/Config/Compat.php b/core/Config/Compat.php
index 742a763412..a37831b6ba 100644
--- a/core/Config/Compat.php
+++ b/core/Config/Compat.php
@@ -24,14 +24,16 @@
class Piwik_Config_Compat_Array
{
private $data;
+ private $parent;
/**
* Constructor
*
* @param array $data configuration section
*/
- public function __construct(array $data)
+ public function __construct($parent, array $data)
{
+ $this->parent = $parent;
$this->data = $data;
}
@@ -44,7 +46,7 @@ class Piwik_Config_Compat_Array
public function __get($name)
{
$tmp = $this->data[$name];
- return is_array($tmp) ? new Piwik_Config_Compat_Array($tmp) : $tmp;
+ return is_array($tmp) ? new Piwik_Config_Compat_Array($this, $tmp) : $tmp;
}
/**
@@ -72,6 +74,14 @@ class Piwik_Config_Compat_Array
{
return $this->data;
}
+
+ /**
+ * Set dirty bit
+ */
+ public function setDirtyBit()
+ {
+ $this->parent->setDirtyBit();
+ }
}
class Piwik_Config_Compat
@@ -79,6 +89,7 @@ class Piwik_Config_Compat
private $config;
private $data;
private $enabled;
+ private $dirty;
/**
* Constructor
@@ -88,6 +99,7 @@ class Piwik_Config_Compat
$this->config = Piwik_Config::getInstance();
$this->data = array();
$this->enabled = true;
+ $this->dirty = false;
}
/**
@@ -95,15 +107,11 @@ class Piwik_Config_Compat
*/
public function __destruct()
{
- if ($this->enabled)
+ if ($this->enabled && $this->dirty)
{
$this->config->forceSave();
- Piwik_Config::getInstance()->clear();
- }
- else
- {
- $this->config->clear();
}
+ $this->config->clear();
}
/**
@@ -120,7 +128,7 @@ class Piwik_Config_Compat
}
$tmp = $this->data[$name];
- return is_array($tmp) ? new Piwik_Config_Compat_Array($tmp) : $tmp;
+ return is_array($tmp) ? new Piwik_Config_Compat_Array($this, $tmp) : $tmp;
}
/**
@@ -137,6 +145,15 @@ class Piwik_Config_Compat
}
$this->config->__set($name, $value);
+ $this->dirty = true;
+ }
+
+ /**
+ * Set dirty bit
+ */
+ public function setDirtyBit()
+ {
+ $this->dirty = true;
}
/**
diff --git a/core/Piwik.php b/core/Piwik.php
index eb203720ba..6ab231f31c 100644
--- a/core/Piwik.php
+++ b/core/Piwik.php
@@ -1,5 +1,4 @@
-<?php
-/**
+<?php /**
* Piwik - Open source web analytics
*
* @link http://piwik.org
diff --git a/core/PluginsManager.php b/core/PluginsManager.php
index 43c356d78a..5debb98fd5 100644
--- a/core/PluginsManager.php
+++ b/core/PluginsManager.php
@@ -131,14 +131,12 @@ class Piwik_PluginsManager
*/
public function deactivatePlugin($pluginName)
{
- $configWriter = Piwik_Config::getInstance();
-
$plugins = $this->pluginsToLoad;
$key = array_search($pluginName, $plugins);
if($key !== false)
{
unset($plugins[$key]);
- $configWriter->Plugins['Plugins'] = $plugins;
+ Piwik_Config::getInstance()->Plugins['Plugins'] = $plugins;
}
$pluginsTracker = Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker'];
@@ -148,12 +146,12 @@ class Piwik_PluginsManager
if($key !== false)
{
unset($pluginsTracker[$key]);
- $configWriter->Plugins_Tracker['Plugins_Tracker'] = $pluginsTracker;
+ Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker'] = $pluginsTracker;
}
}
// Delete merged js/css files to force regenerations to exclude the deactivated plugin
- Piwik_Config::getInstance()->clear();
+ Piwik_Config::getInstance()->forceSave();
Piwik::deleteAllCacheOnUpdate();
}
@@ -207,8 +205,8 @@ class Piwik_PluginsManager
}
// the config file will automatically be saved with the new plugin
- $configWriter = Piwik_Config::getInstance();
- $configWriter->Plugins['Plugins'] = $plugins;
+ Piwik_Config::getInstance()->Plugins['Plugins'] = $plugins;
+ Piwik_Config::getInstance()->forceSave();
// Delete merged js/css files to force regenerations to include the activated plugin
Piwik::deleteAllCacheOnUpdate();
@@ -557,8 +555,7 @@ class Piwik_PluginsManager
{
$this->installPlugin($plugin);
$pluginsInstalled[] = $pluginName;
- $configWriter = Piwik_Config::getInstance();
- $configWriter->PluginsInstalled['PluginsInstalled'] = $pluginsInstalled;
+ Piwik_Config::getInstance()->PluginsInstalled['PluginsInstalled'] = $pluginsInstalled;
}
$information = $plugin->getInformation();
@@ -575,10 +572,11 @@ class Piwik_PluginsManager
if(!in_array($pluginName, $pluginsTracker))
{
$pluginsTracker[] = $pluginName;
- $configWriter = Piwik_Config::getInstance();
- $configWriter->Plugins_Tracker['Plugins_Tracker'] = $pluginsTracker;
+ Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker'] = $pluginsTracker;
}
}
+
+ Piwik_Config::getInstance()->forceSave();
}
}
diff --git a/core/Updates/0.5.4.php b/core/Updates/0.5.4.php
index e40a326d88..9fadcec88d 100644
--- a/core/Updates/0.5.4.php
+++ b/core/Updates/0.5.4.php
@@ -25,16 +25,14 @@ class Piwik_Updates_0_5_4 extends Piwik_Updates
static function update()
{
- $config = Piwik_Config::getInstance();
$salt = Piwik_Common::generateUniqId();
- if(!isset($config->superuser['salt']))
+ if(!isset(Piwik_Config::getInstance()->superuser['salt']))
{
try {
if(is_writable( Piwik_Config::getLocalConfigPath() ))
{
- $config->setConfigOption('superuser', 'salt', $salt);
- $config->__destruct();
- Piwik_Config::getInstance()->clear();
+ Piwik_Config::getInstance()->setConfigOption('superuser', 'salt', $salt);
+ Piwik_Config::getInstance()->forceSave();
}
else
{
@@ -45,17 +43,15 @@ class Piwik_Updates_0_5_4 extends Piwik_Updates
}
}
- $config = Piwik_Config::getInstance();
- $plugins = $config->Plugins;
+ $plugins = Piwik_Config::getInstance()->Plugins;
if(!in_array('MultiSites', $plugins))
{
try {
if(is_writable( Piwik_Config::getLocalConfigPath() ))
{
$plugins[] = 'MultiSites';
- $config->setConfigSection('Plugins', $plugins);
- $config->__destruct();
- Piwik_Config::getInstance()->clear();
+ Piwik_Config::getInstance()->setConfigSection('Plugins', $plugins);
+ Piwik_Config::getInstance()->forceSave();
}
else
{
diff --git a/core/Updates/0.6.3.php b/core/Updates/0.6.3.php
index e0c94747a2..f88e1be185 100644
--- a/core/Updates/0.6.3.php
+++ b/core/Updates/0.6.3.php
@@ -27,16 +27,14 @@ class Piwik_Updates_0_6_3 extends Piwik_Updates
static function update()
{
- $config = Piwik_Config::getInstance();
- $dbInfos = $config->database;
+ $dbInfos = Piwik_Config::getInstance()->database;
if(!isset($dbInfos['schema']))
{
try {
if(is_writable( Piwik_Config::getLocalConfigPath() ))
{
- $config->setConfigOption('database', 'schema', 'Myisam');
- $config->__destruct();
- Piwik_Config::getInstance()->clear();
+ Piwik_Config::getInstance()->setConfigOption('database', 'schema', 'Myisam');
+ Piwik_Config::getInstance()->forceSave();
}
else
{
diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php
index 834e37ff0c..d66d62bbad 100644
--- a/plugins/CoreAdminHome/Controller.php
+++ b/plugins/CoreAdminHome/Controller.php
@@ -88,6 +88,8 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin
// update branding settings
Piwik_Config::getInstance()->branding['use_custom_logo'] = Piwik_Common::getRequestVar('useCustomLogo', '0');
+
+ Piwik_Config::getInstance()->forceSave();
$toReturn = $response->getResponse();
} catch(Exception $e ) {
diff --git a/plugins/Login/Controller.php b/plugins/Login/Controller.php
index 6ce7fef930..f35b90d43d 100644
--- a/plugins/Login/Controller.php
+++ b/plugins/Login/Controller.php
@@ -325,6 +325,7 @@ class Piwik_Login_Controller extends Piwik_Controller
$user['password'] = md5($password);
Piwik_Config::getInstance()->superuser = $user;
+ Piwik_Config::getInstance()->forceSave();
}
else
{
diff --git a/plugins/PrivacyManager/Controller.php b/plugins/PrivacyManager/Controller.php
index b83826a8f4..f48ea48b9f 100644
--- a/plugins/PrivacyManager/Controller.php
+++ b/plugins/PrivacyManager/Controller.php
@@ -17,140 +17,142 @@
class Piwik_PrivacyManager_Controller extends Piwik_Controller_Admin
{
- const ANONYMIZE_IP_PLUGIN_NAME = "AnonymizeIP";
- const OPTION_LAST_DELETE_PIWIK_LOGS = "lastDelete_piwik_logs";
-
- public function index()
- {
- Piwik::checkUserIsSuperUser();
- if ($_SERVER["REQUEST_METHOD"] == "POST")
- {
- switch (Piwik_Common::getRequestVar('form'))
- {
- case("formMaskLength"):
- $this->handlePluginState(Piwik_Common::getRequestVar("anonymizeIPEnable", 0));
- $trackerConfig = Piwik_Config::getInstance()->Tracker;
- $trackerConfig['ip_address_mask_length'] = Piwik_Common::getRequestVar("maskLength", 1);
- Piwik_Config::getInstance()->Tracker = $trackerConfig;
- break;
-
- case("formDeleteSettings"):
- $deleteLogs = Piwik_Config::getInstance()->Deletelogs;
- $deleteLogs['delete_logs_enable'] = Piwik_Common::getRequestVar("deleteEnable", 0);
- $deleteLogs['delete_logs_schedule_lowest_interval'] = Piwik_Common::getRequestVar("deleteLowestInterval", 7);
- $deleteLogs['delete_logs_older_than'] = ((int)Piwik_Common::getRequestVar("deleteOlderThan", 180) < 7) ?
- 7 : Piwik_Common::getRequestVar("deleteOlderThan", 180);
- $deleteLogs['delete_max_rows_per_run'] = Piwik_Common::getRequestVar("deleteMaxRows", 100);
-
- Piwik_Config::getInstance()->Deletelogs = $deleteLogs;
- break;
-
- default: //do nothing
- break;
- }
- }
- return $this->redirectToIndex('PrivacyManager', 'privacySettings', null, null, null, array('updated' => 1));
- }
-
- public function privacySettings()
- {
- Piwik::checkUserHasSomeAdminAccess();
- $view = Piwik_View::factory('privacySettings');
-
- if (Piwik::isUserIsSuperUser())
- {
- $deleteLogs = array();
-
- $view->deleteLogs = $this->getDeleteLogsInfo();
- $view->anonymizeIP = $this->getAnonymizeIPInfo();
- }
- $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
-
- if (!Piwik_Config::getInstance()->isFileWritable())
+ const ANONYMIZE_IP_PLUGIN_NAME = "AnonymizeIP";
+ const OPTION_LAST_DELETE_PIWIK_LOGS = "lastDelete_piwik_logs";
+
+ public function index()
+ {
+ Piwik::checkUserIsSuperUser();
+ if ($_SERVER["REQUEST_METHOD"] == "POST")
+ {
+ switch (Piwik_Common::getRequestVar('form'))
+ {
+ case("formMaskLength"):
+ $this->handlePluginState(Piwik_Common::getRequestVar("anonymizeIPEnable", 0));
+ $trackerConfig = Piwik_Config::getInstance()->Tracker;
+ $trackerConfig['ip_address_mask_length'] = Piwik_Common::getRequestVar("maskLength", 1);
+ Piwik_Config::getInstance()->Tracker = $trackerConfig;
+ Piwik_Config::getInstance()->forceSave();
+ break;
+
+ case("formDeleteSettings"):
+ $deleteLogs = Piwik_Config::getInstance()->Deletelogs;
+ $deleteLogs['delete_logs_enable'] = Piwik_Common::getRequestVar("deleteEnable", 0);
+ $deleteLogs['delete_logs_schedule_lowest_interval'] = Piwik_Common::getRequestVar("deleteLowestInterval", 7);
+ $deleteLogs['delete_logs_older_than'] = ((int)Piwik_Common::getRequestVar("deleteOlderThan", 180) < 7) ?
+ 7 : Piwik_Common::getRequestVar("deleteOlderThan", 180);
+ $deleteLogs['delete_max_rows_per_run'] = Piwik_Common::getRequestVar("deleteMaxRows", 100);
+
+ Piwik_Config::getInstance()->Deletelogs = $deleteLogs;
+ Piwik_Config::getInstance()->forceSave();
+ break;
+
+ default: //do nothing
+ break;
+ }
+ }
+
+ return $this->redirectToIndex('PrivacyManager', 'privacySettings', null, null, null, array('updated' => 1));
+ }
+
+ public function privacySettings()
+ {
+ Piwik::checkUserHasSomeAdminAccess();
+ $view = Piwik_View::factory('privacySettings');
+
+ if (Piwik::isUserIsSuperUser())
+ {
+ $deleteLogs = array();
+
+ $view->deleteLogs = $this->getDeleteLogsInfo();
+ $view->anonymizeIP = $this->getAnonymizeIPInfo();
+ }
+ $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+
+ if (!Piwik_Config::getInstance()->isFileWritable())
+ {
+ $view->configFileNotWritable = true;
+ }
+
+ $this->setBasicVariablesView($view);
+ $view->menu = Piwik_GetAdminMenu();
+
+ echo $view->render();
+ }
+
+ protected function getAnonymizeIPInfo()
{
- $view->configFileNotWritable = true;
- }
-
- $this->setBasicVariablesView($view);
- $view->menu = Piwik_GetAdminMenu();
-
- echo $view->render();
- }
-
- protected function getAnonymizeIPInfo()
- {
- Piwik::checkUserIsSuperUser();
- $anonymizeIP = array();
-
- Piwik_PluginsManager::getInstance()->loadPlugin(self::ANONYMIZE_IP_PLUGIN_NAME);
-
- $anonymizeIP["name"] = self::ANONYMIZE_IP_PLUGIN_NAME;
- $anonymizeIP["enabled"] = Piwik_PluginsManager::getInstance()->isPluginActivated(self::ANONYMIZE_IP_PLUGIN_NAME);
- $anonymizeIP["maskLength"] = Piwik_Config::getInstance()->Tracker['ip_address_mask_length'];
- $anonymizeIP["info"] = Piwik_PluginsManager::getInstance()->getLoadedPlugin(self::ANONYMIZE_IP_PLUGIN_NAME)->getInformation();
-
- return $anonymizeIP;
- }
-
- protected function getDeleteLogsInfo()
- {
- Piwik::checkUserIsSuperUser();
- $deleteLogsInfos = array();
- $taskScheduler = new Piwik_TaskScheduler();
- $deleteLogsInfos["config"] = Piwik_Config::getInstance()->Deletelogs;
- $privacyManager = new Piwik_PrivacyManager();
- $deleteLogsInfos["deleteTables"] = implode(", ", $privacyManager->getDeleteTableLogTables());
-
- $scheduleTimetable = $taskScheduler->getScheduledTimeForTask("Piwik_PrivacyManager", "deleteLogTables");
-
- $optionTable = Piwik_GetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS);
-
- //If task was already rescheduled, read time from taskTimetable. Else, calculate next possible runtime.
- if (!empty($scheduleTimetable) && ($scheduleTimetable - time() > 0)) {
- $nextPossibleSchedule = (int)$scheduleTimetable;
- } else {
- $date = Piwik_Date::factory("today");
- $nextPossibleSchedule = $date->addDay(1)->getTimestamp();
- }
-
- //deletion schedule did not run before
- if (empty($optionTable)) {
- $deleteLogsInfos["lastRun"] = false;
-
- //next run ASAP (with next schedule run)
- $date = Piwik_Date::factory("today");
- $deleteLogsInfos["nextScheduleTime"] = $nextPossibleSchedule;
- } else {
- $deleteLogsInfos["lastRun"] = $optionTable;
- $deleteLogsInfos["lastRunPretty"] = Piwik_Date::factory((int)$optionTable)->getLocalized('%day% %shortMonth% %longYear%');
-
- //Calculate next run based on last run + interval
- $nextScheduleRun = (int)($deleteLogsInfos["lastRun"] + $deleteLogsInfos["config"]["delete_logs_schedule_lowest_interval"] * 24 * 60 * 60);
-
- //is the calculated next run in the past? (e.g. plugin was disabled in the meantime or something) -> run ASAP
- if (($nextScheduleRun - time()) <= 0) {
- $deleteLogsInfos["nextScheduleTime"] = $nextPossibleSchedule;
- } else {
- $deleteLogsInfos["nextScheduleTime"] = $nextScheduleRun;
- }
- }
-
- $deleteLogsInfos["nextRunPretty"] = Piwik::getPrettyTimeFromSeconds($deleteLogsInfos["nextScheduleTime"] - time());
-
- return $deleteLogsInfos;
- }
-
- protected function handlePluginState($state = 0)
- {
- $pluginController = new Piwik_CorePluginsAdmin_Controller();
-
- if ($state == 1 && !Piwik_PluginsManager::getInstance()->isPluginActivated(self::ANONYMIZE_IP_PLUGIN_NAME)) {
- $pluginController->activate($redirectAfter = false);
- } elseif ($state == 0 && Piwik_PluginsManager::getInstance()->isPluginActivated(self::ANONYMIZE_IP_PLUGIN_NAME)) {
- $pluginController->deactivate($redirectAfter = false);
- } else {
- //nothing to do
- }
- }
+ Piwik::checkUserIsSuperUser();
+ $anonymizeIP = array();
+
+ Piwik_PluginsManager::getInstance()->loadPlugin(self::ANONYMIZE_IP_PLUGIN_NAME);
+
+ $anonymizeIP["name"] = self::ANONYMIZE_IP_PLUGIN_NAME;
+ $anonymizeIP["enabled"] = Piwik_PluginsManager::getInstance()->isPluginActivated(self::ANONYMIZE_IP_PLUGIN_NAME);
+ $anonymizeIP["maskLength"] = Piwik_Config::getInstance()->Tracker['ip_address_mask_length'];
+ $anonymizeIP["info"] = Piwik_PluginsManager::getInstance()->getLoadedPlugin(self::ANONYMIZE_IP_PLUGIN_NAME)->getInformation();
+ return $anonymizeIP;
+ }
+
+ protected function getDeleteLogsInfo()
+ {
+ Piwik::checkUserIsSuperUser();
+ $deleteLogsInfos = array();
+ $taskScheduler = new Piwik_TaskScheduler();
+ $deleteLogsInfos["config"] = Piwik_Config::getInstance()->Deletelogs;
+ $privacyManager = new Piwik_PrivacyManager();
+ $deleteLogsInfos["deleteTables"] = implode(", ", $privacyManager->getDeleteTableLogTables());
+
+ $scheduleTimetable = $taskScheduler->getScheduledTimeForTask("Piwik_PrivacyManager", "deleteLogTables");
+
+ $optionTable = Piwik_GetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS);
+
+ //If task was already rescheduled, read time from taskTimetable. Else, calculate next possible runtime.
+ if (!empty($scheduleTimetable) && ($scheduleTimetable - time() > 0)) {
+ $nextPossibleSchedule = (int)$scheduleTimetable;
+ } else {
+ $date = Piwik_Date::factory("today");
+ $nextPossibleSchedule = $date->addDay(1)->getTimestamp();
+ }
+
+ //deletion schedule did not run before
+ if (empty($optionTable)) {
+ $deleteLogsInfos["lastRun"] = false;
+
+ //next run ASAP (with next schedule run)
+ $date = Piwik_Date::factory("today");
+ $deleteLogsInfos["nextScheduleTime"] = $nextPossibleSchedule;
+ } else {
+ $deleteLogsInfos["lastRun"] = $optionTable;
+ $deleteLogsInfos["lastRunPretty"] = Piwik_Date::factory((int)$optionTable)->getLocalized('%day% %shortMonth% %longYear%');
+
+ //Calculate next run based on last run + interval
+ $nextScheduleRun = (int)($deleteLogsInfos["lastRun"] + $deleteLogsInfos["config"]["delete_logs_schedule_lowest_interval"] * 24 * 60 * 60);
+
+ //is the calculated next run in the past? (e.g. plugin was disabled in the meantime or something) -> run ASAP
+ if (($nextScheduleRun - time()) <= 0) {
+ $deleteLogsInfos["nextScheduleTime"] = $nextPossibleSchedule;
+ } else {
+ $deleteLogsInfos["nextScheduleTime"] = $nextScheduleRun;
+ }
+ }
+
+ $deleteLogsInfos["nextRunPretty"] = Piwik::getPrettyTimeFromSeconds($deleteLogsInfos["nextScheduleTime"] - time());
+
+ return $deleteLogsInfos;
+ }
+
+ protected function handlePluginState($state = 0)
+ {
+ $pluginController = new Piwik_CorePluginsAdmin_Controller();
+
+ if ($state == 1 && !Piwik_PluginsManager::getInstance()->isPluginActivated(self::ANONYMIZE_IP_PLUGIN_NAME)) {
+ $pluginController->activate($redirectAfter = false);
+ } elseif ($state == 0 && Piwik_PluginsManager::getInstance()->isPluginActivated(self::ANONYMIZE_IP_PLUGIN_NAME)) {
+ $pluginController->deactivate($redirectAfter = false);
+ } else {
+ //nothing to do
+ }
+ }
}
diff --git a/plugins/UsersManager/Controller.php b/plugins/UsersManager/Controller.php
index 128f25f838..533e9cbb83 100644
--- a/plugins/UsersManager/Controller.php
+++ b/plugins/UsersManager/Controller.php
@@ -282,8 +282,7 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin
$userLogin = Piwik::getCurrentUserLogin();
if(Piwik::isUserIsSuperUser())
{
- $config = Piwik_Config::getInstance();
- $superUser = $config->superuser;
+ $superUser = Piwik_Config::getInstance()->superuser;
$updatedSuperUser = false;
if($newPassword !== false)
@@ -300,7 +299,8 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin
}
if($updatedSuperUser)
{
- $config->superuser = $superUser;
+ Piwik_Config::getInstance()->superuser = $superUser;
+ Piwik_Config::getInstance()->forceSave();
}
}
else
diff --git a/tests/core/Config.test.php b/tests/core/Config.test.php
index 4bed81d15f..6f1419c704 100644
--- a/tests/core/Config.test.php
+++ b/tests/core/Config.test.php
@@ -233,14 +233,14 @@ END_OF_HEADER;
array(),
false,
),
-/*
+
'local copy (different), cached get' => array(
array('General' => array('debug' => '2')),
array('General' => array('debug' => '1')),
array('General' => array('debug' => '2')),
false,
),
-*/ // sub-optimal
+
'local copy (different), cached set' => array(
array('General' => array('debug' => '2')),
array('General' => array('debug' => '1')),
@@ -255,14 +255,14 @@ END_OF_HEADER;
array(),
false,
),
-/*
+
'local copy, cached get, new section' => array(
array('Tracker' => array('anonymize' => '1')),
array('General' => array('debug' => '1')),
array('Tracker' => array('anonymize' => '1')),
false,
),
-*/ // sub-optimal
+
'local copy, cached set local, new section' => array(
array('Tracker' => array('anonymize' => '1')),
array('General' => array('debug' => '1')),