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:
authormattab <matthieu.aubry@gmail.com>2013-10-09 07:17:28 +0400
committermattab <matthieu.aubry@gmail.com>2013-10-09 07:17:28 +0400
commit6d46df58dd4b16a5c8402e34ed018439cbbadee1 (patch)
treeefaeabfe94ab8a601a96c80e1333ae83513f803e
parent9fb5490490913717ccfacec6f597181091be214f (diff)
Refs #4202 removing functions Piwik_GetOption and SetOption. Now use: Option::get and Option::set and Option::delete
-rw-r--r--composer.lock69
-rw-r--r--core/ArchiveProcessor/Rules.php13
-rw-r--r--core/FrontController.php4
-rw-r--r--core/Http.php4
-rw-r--r--core/Option.php106
-rw-r--r--core/PluginsManager.php2
-rw-r--r--core/SettingsPiwik.php4
-rw-r--r--core/TaskScheduler.php4
-rw-r--r--core/Tracker.php2
-rw-r--r--core/Tracker/Cache.php3
-rw-r--r--core/UpdateCheck.php8
-rw-r--r--core/Updater.php4
-rw-r--r--core/Updates/2.0-a13.php3
-rw-r--r--core/ViewDataTable.php2
-rw-r--r--core/functions.php26
-rw-r--r--misc/cron/archive.php16
-rwxr-xr-xplugins/Annotations/AnnotationList.php5
-rw-r--r--plugins/CoreAdminHome/API.php5
-rw-r--r--plugins/CoreUpdater/Controller.php3
-rw-r--r--plugins/DBStats/DBStats.php5
-rwxr-xr-xplugins/DBStats/MySQLMetadataProvider.php5
-rw-r--r--plugins/Login/Login.php6
-rw-r--r--plugins/MobileMessaging/API.php9
-rw-r--r--plugins/MobileMessaging/MobileMessaging.php5
-rw-r--r--plugins/PrivacyManager/Controller.php3
-rw-r--r--plugins/PrivacyManager/PrivacyManager.php17
-rw-r--r--plugins/SitesManager/API.php37
-rwxr-xr-xplugins/UserCountry/GeoIPAutoUpdater.php27
-rwxr-xr-xplugins/UserCountry/LocationProvider.php5
-rw-r--r--plugins/UsersManager/API.php5
-rw-r--r--plugins/UsersManager/UsersManager.php2
-rwxr-xr-xtests/PHPUnit/BenchmarkTestCase.php4
-rw-r--r--tests/PHPUnit/Core/OptionTest.php136
-rw-r--r--tests/PHPUnit/DatabaseTestCase.php2
-rw-r--r--tests/PHPUnit/Integration/ArchiveCronTest.php2
-rwxr-xr-xtests/PHPUnit/IntegrationTestCase.php2
-rw-r--r--tests/PHPUnit/MockPiwikOption.php12
-rwxr-xr-xtests/PHPUnit/Plugins/PrivacyManagerTest.php18
-rwxr-xr-xtests/PHPUnit/proxy/piwik.php2
39 files changed, 326 insertions, 261 deletions
diff --git a/composer.lock b/composer.lock
index 956f407d39..395cf4e41a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -3,7 +3,7 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
- "hash": "4dc75e9d8e28b0f2f3b1f5cb36402142",
+ "hash": "58a326346eb1d9e3f1211c8d8044842a",
"packages": [
{
"name": "leafo/lessphp",
@@ -47,17 +47,70 @@
"time": "2013-03-02 16:13:31"
},
{
+ "name": "symfony/console",
+ "version": "v2.3.5",
+ "target-dir": "Symfony/Component/Console",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Console.git",
+ "reference": "f880062d56edefb25b36f2defa65aafe65959dc7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/Console/zipball/f880062d56edefb25b36f2defa65aafe65959dc7",
+ "reference": "f880062d56edefb25b36f2defa65aafe65959dc7",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "symfony/event-dispatcher": "~2.1"
+ },
+ "suggest": {
+ "symfony/event-dispatcher": ""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.3-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Console\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Console Component",
+ "homepage": "http://symfony.com",
+ "time": "2013-09-25 06:04:15"
+ },
+ {
"name": "twig/twig",
- "version": "v1.13.1",
+ "version": "v1.14.0",
"source": {
"type": "git",
"url": "https://github.com/fabpot/Twig.git",
- "reference": "v1.13.1"
+ "reference": "224fc55635d544a2ec8edb3592be18db5a093f59"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/fabpot/Twig/zipball/v1.13.1",
- "reference": "v1.13.1",
+ "url": "https://api.github.com/repos/fabpot/Twig/zipball/224fc55635d544a2ec8edb3592be18db5a093f59",
+ "reference": "224fc55635d544a2ec8edb3592be18db5a093f59",
"shasum": ""
},
"require": {
@@ -66,7 +119,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.13-dev"
+ "dev-master": "1.14-dev"
}
},
"autoload": {
@@ -76,7 +129,7 @@
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "BSD-3"
+ "BSD-3-Clause"
],
"authors": [
{
@@ -93,7 +146,7 @@
"keywords": [
"templating"
],
- "time": "2013-06-06 06:06:01"
+ "time": "2013-10-03 06:41:20"
}
],
"packages-dev": [
diff --git a/core/ArchiveProcessor/Rules.php b/core/ArchiveProcessor/Rules.php
index 18f13703ac..1589757187 100644
--- a/core/ArchiveProcessor/Rules.php
+++ b/core/ArchiveProcessor/Rules.php
@@ -15,6 +15,7 @@ use Piwik\Common;
use Piwik\Config;
use Piwik\Date;
use Piwik\Log;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Segment;
use Piwik\SettingsPiwik;
@@ -114,7 +115,7 @@ class Rules
return false;
}
$key = self::FLAG_TABLE_PURGED . "blob_" . $date->toString('Y_m');
- $timestamp = Piwik_GetOption($key);
+ $timestamp = Option::get($key);
// we shall purge temporary archives after their timeout is finished, plus an extra 6 hours
// in case archiving is disabled or run once a day, we give it this extra time to run
@@ -130,7 +131,7 @@ class Rules
&& (!$timestamp
|| $timestamp < time() - $purgeEveryNSeconds)
) {
- Piwik_SetOption($key, time());
+ Option::set($key, time());
if (self::isBrowserTriggerEnabled()) {
// If Browser Archiving is enabled, it is likely there are many more temporary archives
@@ -176,12 +177,12 @@ class Rules
if ($timeToLiveSeconds <= 0) {
throw new Exception(Piwik_TranslateException('General_ExceptionInvalidArchiveTimeToLive'));
}
- Piwik_SetOption(self::OPTION_TODAY_ARCHIVE_TTL, $timeToLiveSeconds, $autoLoad = true);
+ Option::set(self::OPTION_TODAY_ARCHIVE_TTL, $timeToLiveSeconds, $autoLoad = true);
}
public static function getTodayArchiveTimeToLive()
{
- $timeToLive = Piwik_GetOption(self::OPTION_TODAY_ARCHIVE_TTL);
+ $timeToLive = Option::get(self::OPTION_TODAY_ARCHIVE_TTL);
if ($timeToLive !== false) {
return $timeToLive;
}
@@ -223,7 +224,7 @@ class Rules
public static function isBrowserTriggerEnabled()
{
- $browserArchivingEnabled = Piwik_GetOption(self::OPTION_BROWSER_TRIGGER_ARCHIVING);
+ $browserArchivingEnabled = Option::get(self::OPTION_BROWSER_TRIGGER_ARCHIVING);
if ($browserArchivingEnabled !== false) {
return (bool)$browserArchivingEnabled;
}
@@ -235,7 +236,7 @@ class Rules
if (!is_bool($enabled)) {
throw new Exception('Browser trigger archiving must be set to true or false.');
}
- Piwik_SetOption(self::OPTION_BROWSER_TRIGGER_ARCHIVING, (int)$enabled, $autoLoad = true);
+ Option::set(self::OPTION_BROWSER_TRIGGER_ARCHIVING, (int)$enabled, $autoLoad = true);
Cache::clearCacheGeneral();
}
} \ No newline at end of file
diff --git a/core/FrontController.php b/core/FrontController.php
index e1068e46d8..ebed44b919 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -307,11 +307,11 @@ class FrontController
try {
Db::createDatabaseObject();
- Piwik_GetOption('TestingIfDatabaseConnectionWorked');
+ Option::get('TestingIfDatabaseConnectionWorked');
} catch (Exception $exception) {
if (self::shouldRethrowException()) {
throw $exception;
- }
+ }
/**
* This event is triggered in case a config file is not in the correct format or in case required values
diff --git a/core/Http.php b/core/Http.php
index 2b30cc620d..ddd773999f 100644
--- a/core/Http.php
+++ b/core/Http.php
@@ -581,9 +581,9 @@ class Http
throw new Exception(Piwik_Translate('General_DownloadFail_HttpRequestFail'));
}
- Piwik_SetOption($downloadOption, $expectedFileSize);
+ Option::set($downloadOption, $expectedFileSize);
} else {
- $expectedFileSize = (int)Piwik_GetOption($downloadOption);
+ $expectedFileSize = (int)Option::get($downloadOption);
if ($expectedFileSize === false) { // sanity check
throw new Exception("Trying to continue a download that never started?! That's not supposed to happen...");
}
diff --git a/core/Option.php b/core/Option.php
index 3e4ad542d3..b784fe0f63 100644
--- a/core/Option.php
+++ b/core/Option.php
@@ -21,6 +21,65 @@ namespace Piwik;
class Option
{
/**
+ * Returns the option value for the requested option $name, fetching from database, if not in cache.
+ *
+ * @param string $name Key
+ * @return string|bool Value or false, if not found
+ */
+ public static function get($name)
+ {
+ return self::getInstance()->getValue($name);
+ }
+
+ /**
+ * Sets the option value in the database and cache
+ *
+ * @param string $name
+ * @param string $value
+ * @param int $autoLoad if set to 1, this option value will be automatically loaded; should be set to 1 for options that will always be used in the Piwik request.
+ */
+ public static function set($name, $value, $autoload = 0)
+ {
+ return self::getInstance()->setValue($name, $value, $autoload);
+ }
+
+ /**
+ * Delete key-value pair from database and reload cache.
+ *
+ * @param string $name Key to match exactly
+ * @param string $value Optional value
+ */
+ public static function delete($name, $value = null)
+ {
+ return self::getInstance()->deleteValue($name, $value);
+ }
+
+ /**
+ * Delete key-value pair(s) from database and reload cache.
+ * The supplied pattern should use '%' as wildcards, and literal '_' should be escaped.
+ *
+ * @param string $name Pattern of key to match.
+ * @param string $value Optional value
+ */
+ public static function deleteLike($name, $value = null)
+ {
+ return self::getInstance()->deleteNameLike($name, $value);
+ }
+
+ /**
+ * Clears the cache
+ * Used in unit tests to reset the state of the object between tests
+ *
+ * @return void
+ */
+ public static function clearCache()
+ {
+ $option = self::getInstance();
+ $option->loaded = false;
+ $option->all = array();
+ }
+
+ /**
* @var array
*/
private $all = array();
@@ -41,7 +100,7 @@ class Option
*
* @return \Piwik\Option
*/
- static public function getInstance()
+ static private function getInstance()
{
if (self::$instance == null) {
self::$instance = new self;
@@ -56,13 +115,7 @@ class Option
{
}
- /**
- * Returns the option value for the requested option $name, fetching from database, if not in cache.
- *
- * @param string $name Key
- * @return string|bool Value or false, if not found
- */
- public function get($name)
+ private function getValue($name)
{
$this->autoload();
if (isset($this->all[$name])) {
@@ -78,14 +131,7 @@ class Option
return $value;
}
- /**
- * Sets the option value in the database and cache
- *
- * @param string $name
- * @param string $value
- * @param int $autoLoad if set to 1, this option value will be automatically loaded; should be set to 1 for options that will always be used in the Piwik request.
- */
- public function set($name, $value, $autoLoad = 0)
+ private function setValue($name, $value, $autoLoad = 0)
{
$autoLoad = (int)$autoLoad;
Db::query('INSERT INTO `' . Common::prefixTable('option') . '` (option_name, option_value, autoload) ' .
@@ -95,13 +141,7 @@ class Option
$this->all[$name] = $value;
}
- /**
- * Delete key-value pair from database and reload cache.
- *
- * @param string $name Key to match exactly
- * @param string $value Optional value
- */
- public function delete($name, $value = null)
+ private function deleteValue($name, $value)
{
$sql = 'DELETE FROM `' . Common::prefixTable('option') . '` WHERE option_name = ?';
$bind[] = $name;
@@ -116,14 +156,7 @@ class Option
$this->clearCache();
}
- /**
- * Delete key-value pair(s) from database and reload cache.
- * The supplied pattern should use '%' as wildcards, and literal '_' should be escaped.
- *
- * @param string $name Pattern of key to match.
- * @param string $value Optional value
- */
- public function deleteLike($name, $value = null)
+ private function deleteNameLike($name, $value = null)
{
$sql = 'DELETE FROM `' . Common::prefixTable('option') . '` WHERE option_name LIKE ?';
$bind[] = $name;
@@ -159,15 +192,4 @@ class Option
$this->loaded = true;
}
- /**
- * Clears the cache
- * Used in unit tests to reset the state of the object between tests
- *
- * @return void
- */
- public function clearCache()
- {
- $this->loaded = false;
- $this->all = array();
- }
}
diff --git a/core/PluginsManager.php b/core/PluginsManager.php
index fbe39c40bd..605451e145 100644
--- a/core/PluginsManager.php
+++ b/core/PluginsManager.php
@@ -204,7 +204,7 @@ class PluginsManager
$this->returnLoadedPluginsInfo();
$plugin = $this->getLoadedPlugin($pluginName);
$plugin->uninstall();
- Option::getInstance()->delete('version_' . $pluginName);
+ Option::delete('version_' . $pluginName);
$this->removePluginFromPluginsConfig($pluginName);
$this->removePluginFromPluginsInstalledConfig($pluginName);
diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php
index 5dd9d61920..6662b11a39 100644
--- a/core/SettingsPiwik.php
+++ b/core/SettingsPiwik.php
@@ -125,7 +125,7 @@ class SettingsPiwik
}
$key = 'piwikUrl';
- $url = Piwik_GetOption($key);
+ $url = Option::get($key);
if (Common::isPhpCliMode()
// in case archive.php is triggered with domain localhost
|| SettingsServer::isArchivePhpTriggered()
@@ -141,7 +141,7 @@ class SettingsPiwik
|| $currentUrl != $url
) {
if (strlen($currentUrl) >= strlen('http://a/')) {
- Piwik_SetOption($key, $currentUrl, $autoLoad = true);
+ Option::set($key, $currentUrl, $autoLoad = true);
}
$url = $currentUrl;
}
diff --git a/core/TaskScheduler.php b/core/TaskScheduler.php
index a81268c4c9..80bbc25f7a 100644
--- a/core/TaskScheduler.php
+++ b/core/TaskScheduler.php
@@ -103,7 +103,7 @@ class TaskScheduler
if (self::taskShouldBeRescheduled($taskName, $timetable)) {
// update the scheduled time
$timetable[$taskName] = $task->getRescheduledTime();
- Piwik_SetOption(self::TIMETABLE_OPTION_STRING, serialize($timetable));
+ Option::set(self::TIMETABLE_OPTION_STRING, serialize($timetable));
}
}
}
@@ -186,7 +186,7 @@ class TaskScheduler
static private function getTimetableFromOptionTable()
{
- return self::getTimetableFromOptionValue(Piwik_GetOption(self::TIMETABLE_OPTION_STRING));
+ return self::getTimetableFromOptionValue(Option::get(self::TIMETABLE_OPTION_STRING));
}
/**
diff --git a/core/Tracker.php b/core/Tracker.php
index 0db9fb2adf..0d3a00ee9b 100644
--- a/core/Tracker.php
+++ b/core/Tracker.php
@@ -353,7 +353,7 @@ class Tracker
$cache['lastTrackerCronRun'] = $now;
Cache::setCacheGeneral($cache);
self::initCorePiwikInTrackerMode();
- Piwik_SetOption('lastTrackerCronRun', $cache['lastTrackerCronRun']);
+ Option::set('lastTrackerCronRun', $cache['lastTrackerCronRun']);
Common::printDebug('-> Scheduled Tasks: Starting...');
// save current user privilege and temporarily assume super user privilege
diff --git a/core/Tracker/Cache.php b/core/Tracker/Cache.php
index 948d1a34ad..ae328aed38 100644
--- a/core/Tracker/Cache.php
+++ b/core/Tracker/Cache.php
@@ -13,6 +13,7 @@ namespace Piwik\Tracker;
use Piwik\ArchiveProcessor\Rules;
use Piwik\CacheFile;
use Piwik\Config;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Tracker;
@@ -106,7 +107,7 @@ class Cache
Tracker::initCorePiwikInTrackerMode();
$cacheContent = array(
'isBrowserTriggerEnabled' => Rules::isBrowserTriggerEnabled(),
- 'lastTrackerCronRun' => Piwik_GetOption('lastTrackerCronRun'),
+ 'lastTrackerCronRun' => Option::get('lastTrackerCronRun'),
);
/**
diff --git a/core/UpdateCheck.php b/core/UpdateCheck.php
index a677abdd43..f1ba7edb9a 100644
--- a/core/UpdateCheck.php
+++ b/core/UpdateCheck.php
@@ -38,13 +38,13 @@ class UpdateCheck
$interval = self::CHECK_INTERVAL;
}
- $lastTimeChecked = Piwik_GetOption(self::LAST_TIME_CHECKED);
+ $lastTimeChecked = Option::get(self::LAST_TIME_CHECKED);
if ($force
|| $lastTimeChecked === false
|| time() - $interval > $lastTimeChecked
) {
// set the time checked first, so that parallel Piwik requests don't all trigger the http requests
- Piwik_SetOption(self::LAST_TIME_CHECKED, time(), $autoLoad = 1);
+ Option::set(self::LAST_TIME_CHECKED, time(), $autoLoad = 1);
$parameters = array(
'piwik_version' => Version::VERSION,
'php_version' => PHP_VERSION,
@@ -71,7 +71,7 @@ class UpdateCheck
// e.g., disable_functions = fsockopen; allow_url_open = Off
$latestVersion = '';
}
- Piwik_SetOption(self::LATEST_VERSION, $latestVersion);
+ Option::set(self::LATEST_VERSION, $latestVersion);
}
}
@@ -83,7 +83,7 @@ class UpdateCheck
*/
public static function isNewestVersionAvailable()
{
- $latestVersion = Piwik_GetOption(self::LATEST_VERSION);
+ $latestVersion = Option::get(self::LATEST_VERSION);
if (!empty($latestVersion)
&& version_compare(Version::VERSION, $latestVersion) == -1
) {
diff --git a/core/Updater.php b/core/Updater.php
index 0bbc6280ae..1ccdb78e18 100644
--- a/core/Updater.php
+++ b/core/Updater.php
@@ -55,7 +55,7 @@ class Updater
public static function recordComponentSuccessfullyUpdated($name, $version)
{
try {
- Piwik_SetOption(self::getNameInOptionTable($name), $version, $autoLoad = 1);
+ Option::set(self::getNameInOptionTable($name), $version, $autoLoad = 1);
} catch (\Exception $e) {
// case when the option table is not yet created (before 0.2.10)
}
@@ -245,7 +245,7 @@ class Updater
foreach ($this->componentsToCheck as $name => $version) {
try {
- $currentVersion = Piwik_GetOption(self::getNameInOptionTable($name));
+ $currentVersion = Option::get(self::getNameInOptionTable($name));
} catch (\Exception $e) {
// mysql error 1146: table doesn't exist
if (Db::get()->isErrNo($e, '1146')) {
diff --git a/core/Updates/2.0-a13.php b/core/Updates/2.0-a13.php
index fac9982240..1e4c0145f4 100644
--- a/core/Updates/2.0-a13.php
+++ b/core/Updates/2.0-a13.php
@@ -13,6 +13,7 @@ namespace Piwik\Updates;
use Piwik\Common;
use Piwik\Db;
use Piwik\Filesystem;
+use Piwik\Option;
use Piwik\Updater;
use Piwik\Updates;
@@ -50,7 +51,7 @@ class Updates_2_0_a13 extends Updates
public static function update()
{
// delete schema version_
- \Piwik\Option::getInstance()->delete('version_Referers');
+ Option::delete('version_Referers');
Updater::updateDatabase(__FILE__, self::getSql());
diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php
index 1977cf8243..9bf0a4b544 100644
--- a/core/ViewDataTable.php
+++ b/core/ViewDataTable.php
@@ -1144,7 +1144,7 @@ class ViewDataTable
// if it's likely that the report data for this data table has been purged,
// set whether we should display a message to that effect.
$view->showReportDataWasPurgedMessage = $this->hasReportBeenPurged();
- $view->deleteReportsOlderThan = Piwik_GetOption('delete_reports_older_than');
+ $view->deleteReportsOlderThan = Option::get('delete_reports_older_than');
}
$view->idSubtable = $this->idSubtable;
$view->clientSideParameters = $this->getClientSideParametersToSet();
diff --git a/core/functions.php b/core/functions.php
index 6cca433647..38fae1c387 100644
--- a/core/functions.php
+++ b/core/functions.php
@@ -61,32 +61,6 @@ namespace {
}
}
-
- /**
- * Returns the option value for the requested option $name
- *
- * @param string $name Key
- * @return string|bool Value or false, if not found
- * @api
- */
- function Piwik_GetOption($name)
- {
- return Piwik\Option::getInstance()->get($name);
- }
-
- /**
- * Sets the option value in the database
- *
- * @param string $name
- * @param string $value
- * @param int $autoLoad if set to 1, this option value will be automatically loaded; should be set to 1 for options that will always be used in the Piwik request.
- * @api
- */
- function Piwik_SetOption($name, $value, $autoLoad = 0)
- {
- Piwik\Option::getInstance()->set($name, $value, $autoLoad);
- }
-
/**
* Returns the AdminMenu
*
diff --git a/misc/cron/archive.php b/misc/cron/archive.php
index 4fecde5662..61cdb807c9 100644
--- a/misc/cron/archive.php
+++ b/misc/cron/archive.php
@@ -223,8 +223,8 @@ class CronArchive
$lastTimestampWebsiteProcessedPeriods = $lastTimestampWebsiteProcessedDay = false;
if (!$this->shouldResetState) {
- $lastTimestampWebsiteProcessedPeriods = Piwik_GetOption($this->lastRunKey($idsite, "periods"));
- $lastTimestampWebsiteProcessedDay = Piwik_GetOption($this->lastRunKey($idsite, "day"));
+ $lastTimestampWebsiteProcessedPeriods = Option::get($this->lastRunKey($idsite, "periods"));
+ $lastTimestampWebsiteProcessedDay = Option::get($this->lastRunKey($idsite, "day"));
}
// For period other than days, we only re-process the reports at most
@@ -272,7 +272,7 @@ class CronArchive
// Fake that the request is already done, so that other archive.php
// running do not grab the same website from the queue
- Piwik_SetOption($this->lastRunKey($idsite, "day"), time());
+ Option::set($this->lastRunKey($idsite, "day"), time());
$url = $this->getVisitsRequestUrl($idsite, "day",
// when some data was purged from this website
@@ -292,7 +292,7 @@ class CronArchive
|| count($response) == 0
) {
// cancel the succesful run flag
- Piwik_SetOption($this->lastRunKey($idsite, "day"), 0);
+ Option::set($this->lastRunKey($idsite, "day"), 0);
$this->log("WARNING: Empty or invalid response '$content' for website id $idsite, " . $timerWebsite->__toString() . ", skipping");
$skipped++;
@@ -334,7 +334,7 @@ class CronArchive
}
// Record succesful run of this website's periods archiving
if ($success) {
- Piwik_SetOption($this->lastRunKey($idsite, "periods"), time());
+ Option::set($this->lastRunKey($idsite, "periods"), time());
// Remove this website from the list of websites to be invalidated
// since it's now just been re-processing the reports, job is done!
@@ -345,7 +345,7 @@ class CronArchive
if ($found !== false) {
unset($websiteIdsInvalidated[$found]);
// $this->log("Websites left to invalidate: " . implode(", ", $websiteIdsInvalidated));
- Piwik_SetOption(APICoreAdminHome::OPTION_INVALIDATED_IDSITES, serialize($websiteIdsInvalidated));
+ Option::set(APICoreAdminHome::OPTION_INVALIDATED_IDSITES, serialize($websiteIdsInvalidated));
}
}
}
@@ -548,7 +548,7 @@ class CronArchive
$this->logFatalError($summary);
} else {
// No error -> Logs the successful script execution until completion
- Piwik_SetOption(self::OPTION_ARCHIVING_FINISHED_TS, time());
+ Option::set(self::OPTION_ARCHIVING_FINISHED_TS, time());
}
}
@@ -739,7 +739,7 @@ class CronArchive
$this->shouldArchiveAllWebsites = true;
}
- $this->timeLastCompleted = Piwik_GetOption(self::OPTION_ARCHIVING_FINISHED_TS);
+ $this->timeLastCompleted = Option::get(self::OPTION_ARCHIVING_FINISHED_TS);
if ($this->shouldResetState) {
$this->timeLastCompleted = false;
}
diff --git a/plugins/Annotations/AnnotationList.php b/plugins/Annotations/AnnotationList.php
index 9f114608e6..deca05a557 100755
--- a/plugins/Annotations/AnnotationList.php
+++ b/plugins/Annotations/AnnotationList.php
@@ -12,6 +12,7 @@ namespace Piwik\Plugins\Annotations;
use Exception;
use Piwik\Date;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Site;
@@ -107,7 +108,7 @@ class AnnotationList
$this->checkIdSiteIsLoaded($idSite);
$optionName = self::getAnnotationCollectionOptionName($idSite);
- Piwik_SetOption($optionName, serialize($this->annotations[$idSite]));
+ Option::set($optionName, serialize($this->annotations[$idSite]));
}
/**
@@ -312,7 +313,7 @@ class AnnotationList
$result = array();
foreach ($this->idSites as $id) {
$optionName = self::getAnnotationCollectionOptionName($id);
- $serialized = Piwik_GetOption($optionName);
+ $serialized = Option::get($optionName);
if ($serialized !== false) {
$result[$id] = unserialize($serialized);
diff --git a/plugins/CoreAdminHome/API.php b/plugins/CoreAdminHome/API.php
index 8c52b97b09..909a178738 100644
--- a/plugins/CoreAdminHome/API.php
+++ b/plugins/CoreAdminHome/API.php
@@ -16,6 +16,7 @@ use Piwik\Config;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Date;
use Piwik\Db;
+use Piwik\Option;
use Piwik\Period;
use Piwik\Period\Week;
use Piwik\Piwik;
@@ -195,7 +196,7 @@ class API
$invalidatedIdSites = array_merge($invalidatedIdSites, $idSites);
$invalidatedIdSites = array_unique($invalidatedIdSites);
$invalidatedIdSites = array_values($invalidatedIdSites);
- Piwik_SetOption(self::OPTION_INVALIDATED_IDSITES, serialize($invalidatedIdSites));
+ Option::set(self::OPTION_INVALIDATED_IDSITES, serialize($invalidatedIdSites));
Site::clearCache();
@@ -221,7 +222,7 @@ class API
static public function getWebsiteIdsToInvalidate()
{
Piwik::checkUserHasSomeAdminAccess();
- $invalidatedIdSites = Piwik_GetOption(self::OPTION_INVALIDATED_IDSITES);
+ $invalidatedIdSites = Option::get(self::OPTION_INVALIDATED_IDSITES);
if ($invalidatedIdSites
&& ($invalidatedIdSites = unserialize($invalidatedIdSites))
&& count($invalidatedIdSites)
diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php
index 59b6645af0..d2474acf68 100644
--- a/plugins/CoreUpdater/Controller.php
+++ b/plugins/CoreUpdater/Controller.php
@@ -19,6 +19,7 @@ use Piwik\DbHelper;
use Piwik\Filechecks;
use Piwik\Filesystem;
use Piwik\Http;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Plugins\LanguagesManager\LanguagesManager;
use Piwik\SettingsPiwik;
@@ -311,7 +312,7 @@ class Controller extends \Piwik\Controller
} else {
$this->errorMessages = array();
try {
- $currentVersion = Piwik_GetOption('version_core');
+ $currentVersion = Option::get('version_core');
} catch (Exception $e) {
$currentVersion = '<= 0.2.9';
}
diff --git a/plugins/DBStats/DBStats.php b/plugins/DBStats/DBStats.php
index 7a042565b6..8a9915051b 100644
--- a/plugins/DBStats/DBStats.php
+++ b/plugins/DBStats/DBStats.php
@@ -13,6 +13,7 @@ namespace Piwik\Plugins\DBStats;
use Piwik\Common;
use Piwik\Date;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\ScheduledTask;
use Piwik\ScheduledTime\Weekly;
@@ -72,7 +73,7 @@ class DBStats extends \Piwik\Plugin
$api->getIndividualMetricsSummary(true);
$now = Date::now()->getLocalized("%longYear%, %shortMonth% %day%");
- Piwik_SetOption(self::TIME_OF_LAST_TASK_RUN_OPTION, $now);
+ Option::set(self::TIME_OF_LAST_TASK_RUN_OPTION, $now);
}
public function getStylesheetFiles(&$stylesheets)
@@ -83,7 +84,7 @@ class DBStats extends \Piwik\Plugin
/** Returns the date when the cacheDataByArchiveNameReports was last run. */
public static function getDateOfLastCachingRun()
{
- return Piwik_GetOption(self::TIME_OF_LAST_TASK_RUN_OPTION);
+ return Option::get(self::TIME_OF_LAST_TASK_RUN_OPTION);
}
public function getReportDisplayProperties(&$properties)
diff --git a/plugins/DBStats/MySQLMetadataProvider.php b/plugins/DBStats/MySQLMetadataProvider.php
index 3a9dc5ed1d..fe7d722fd4 100755
--- a/plugins/DBStats/MySQLMetadataProvider.php
+++ b/plugins/DBStats/MySQLMetadataProvider.php
@@ -16,6 +16,7 @@ use Piwik\Config;
use Piwik\DataTable;
use Piwik\Db;
use Piwik\DbHelper;
+use Piwik\Option;
/**
* Utility class that provides general information about databases, including the size of
@@ -227,7 +228,7 @@ class MySQLMetadataProvider
$dataTableOptionName = $this->getCachedOptionName($status['Name'], 'byArchiveName');
// if option exists && !$forceCache, use the cached data, otherwise create the
- $cachedData = Piwik_GetOption($dataTableOptionName);
+ $cachedData = Option::get($dataTableOptionName);
if ($cachedData !== false && !$forceCache) {
$table = new DataTable();
$table->addRowsFromSerializedArray($cachedData);
@@ -243,7 +244,7 @@ class MySQLMetadataProvider
$serializedTables = $table->getSerialized();
$serializedTable = reset($serializedTables);
- Piwik_SetOption($dataTableOptionName, $serializedTable);
+ Option::set($dataTableOptionName, $serializedTable);
}
// add estimated_size column
diff --git a/plugins/Login/Login.php b/plugins/Login/Login.php
index 5a55e33f5e..fd242c3230 100644
--- a/plugins/Login/Login.php
+++ b/plugins/Login/Login.php
@@ -144,7 +144,7 @@ class Login extends \Piwik\Plugin
$optionName = self::getPasswordResetInfoOptionName($login);
$optionData = UsersManager::getPasswordHash($password);
- Piwik_SetOption($optionName, $optionData);
+ Option::set($optionName, $optionData);
}
/**
@@ -155,7 +155,7 @@ class Login extends \Piwik\Plugin
public static function removePasswordResetInfo($login)
{
$optionName = self::getPasswordResetInfoOptionName($login);
- Option::getInstance()->delete($optionName);
+ Option::delete($optionName);
}
/**
@@ -167,7 +167,7 @@ class Login extends \Piwik\Plugin
public static function getPasswordToResetTo($login)
{
$optionName = self::getPasswordResetInfoOptionName($login);
- return Piwik_GetOption($optionName);
+ return Option::get($optionName);
}
/**
diff --git a/plugins/MobileMessaging/API.php b/plugins/MobileMessaging/API.php
index 538cbee1cc..3b345e94c4 100644
--- a/plugins/MobileMessaging/API.php
+++ b/plugins/MobileMessaging/API.php
@@ -11,6 +11,7 @@
namespace Piwik\Plugins\MobileMessaging;
use Piwik\Common;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Plugins\MobileMessaging\SMSProvider;
use Piwik\Plugins\ScheduledReports\API as APIScheduledReports;
@@ -401,7 +402,7 @@ class API
private function setUserSettings($user, $settings)
{
- Piwik_SetOption(
+ Option::set(
$user . MobileMessaging::USER_SETTINGS_POSTFIX_OPTION,
Common::json_encode($settings)
);
@@ -425,7 +426,7 @@ class API
private function getUserSettings($user)
{
$optionIndex = $user . MobileMessaging::USER_SETTINGS_POSTFIX_OPTION;
- $userSettings = Piwik_GetOption($optionIndex);
+ $userSettings = Option::get($optionIndex);
if (empty($userSettings)) {
$userSettings = array();
@@ -454,7 +455,7 @@ class API
public function setDelegatedManagement($delegatedManagement)
{
Piwik::checkUserIsSuperUser();
- Piwik_SetOption(MobileMessaging::DELEGATED_MANAGEMENT_OPTION, $delegatedManagement);
+ Option::set(MobileMessaging::DELEGATED_MANAGEMENT_OPTION, $delegatedManagement);
}
/**
@@ -465,6 +466,6 @@ class API
public function getDelegatedManagement()
{
Piwik::checkUserHasSomeViewAccess();
- return Piwik_GetOption(MobileMessaging::DELEGATED_MANAGEMENT_OPTION) == 'true';
+ return Option::get(MobileMessaging::DELEGATED_MANAGEMENT_OPTION) == 'true';
}
}
diff --git a/plugins/MobileMessaging/MobileMessaging.php b/plugins/MobileMessaging/MobileMessaging.php
index bca9f4a2e9..34017d1956 100644
--- a/plugins/MobileMessaging/MobileMessaging.php
+++ b/plugins/MobileMessaging/MobileMessaging.php
@@ -10,6 +10,7 @@
*/
namespace Piwik\Plugins\MobileMessaging;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Plugins\API\API as APIPlugins;
use Piwik\Plugins\MobileMessaging\API as APIMobileMessaging;
@@ -236,9 +237,9 @@ class MobileMessaging extends \Piwik\Plugin
function install()
{
- $delegatedManagement = Piwik_GetOption(self::DELEGATED_MANAGEMENT_OPTION);
+ $delegatedManagement = Option::get(self::DELEGATED_MANAGEMENT_OPTION);
if (empty($delegatedManagement)) {
- Piwik_SetOption(self::DELEGATED_MANAGEMENT_OPTION, self::DELEGATED_MANAGEMENT_OPTION_DEFAULT);
+ Option::set(self::DELEGATED_MANAGEMENT_OPTION, self::DELEGATED_MANAGEMENT_OPTION_DEFAULT);
}
}
diff --git a/plugins/PrivacyManager/Controller.php b/plugins/PrivacyManager/Controller.php
index 1a8debbdc4..3a29c285b4 100644
--- a/plugins/PrivacyManager/Controller.php
+++ b/plugins/PrivacyManager/Controller.php
@@ -15,6 +15,7 @@ use Piwik\Config;
use Piwik\Date;
use Piwik\Db;
use Piwik\MetricsFormatter;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Plugins\DBStats\MySQLMetadataProvider;
use Piwik\Plugins\LanguagesManager\LanguagesManager;
@@ -245,7 +246,7 @@ class Controller extends \Piwik\Controller\Admin
$scheduleTimetable = $taskScheduler->getScheduledTimeForMethod("PrivacyManager", "deleteLogTables");
- $optionTable = Piwik_GetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS);
+ $optionTable = Option::get(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)) {
diff --git a/plugins/PrivacyManager/PrivacyManager.php b/plugins/PrivacyManager/PrivacyManager.php
index 006afd77cd..7c1880cc3f 100644
--- a/plugins/PrivacyManager/PrivacyManager.php
+++ b/plugins/PrivacyManager/PrivacyManager.php
@@ -17,6 +17,7 @@ use Piwik\Date;
use Piwik\Db;
use Piwik\Metrics;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Plugins\Goals\Archiver;
use Piwik\ScheduledTask;
@@ -132,7 +133,7 @@ class PrivacyManager extends \Piwik\Plugin
// load the settings for the data purging settings
foreach (self::$defaultPurgeDataOptions as $optionName => $defaultValue) {
- $value = Piwik_GetOption($optionName);
+ $value = Option::get($optionName);
if ($value !== false) {
$settings[$optionName] = $value;
} else {
@@ -142,7 +143,7 @@ class PrivacyManager extends \Piwik\Plugin
}
// option is not saved in the DB, so save it now
- Piwik_SetOption($optionName, $settings[$optionName]);
+ Option::set($optionName, $settings[$optionName]);
}
}
@@ -160,7 +161,7 @@ class PrivacyManager extends \Piwik\Plugin
foreach (self::$defaultPurgeDataOptions as $optionName => $defaultValue) {
if (isset($settings[$optionName])) {
- Piwik_SetOption($optionName, $settings[$optionName]);
+ Option::set($optionName, $settings[$optionName]);
}
}
}
@@ -199,7 +200,7 @@ class PrivacyManager extends \Piwik\Plugin
}
// set last run time
- Piwik_SetOption(self::OPTION_LAST_DELETE_PIWIK_REPORTS, Date::factory('today')->getTimestamp());
+ Option::set(self::OPTION_LAST_DELETE_PIWIK_REPORTS, Date::factory('today')->getTimestamp());
ReportsPurger::make($settings, self::getAllMetricsToKeep())->purgeData();
}
@@ -237,7 +238,7 @@ class PrivacyManager extends \Piwik\Plugin
* every time, when the schedule is triggered.
*/
$lastDeleteDate = Date::factory("today")->getTimestamp();
- Piwik_SetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDeleteDate);
+ Option::set(self::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDeleteDate);
// execute the purge
LogDataPurger::make($settings)->purgeData();
@@ -370,14 +371,14 @@ class PrivacyManager extends \Piwik\Plugin
{
// Log deletion may not run until it is once rescheduled (initial run). This is the
// only way to guarantee the calculated next scheduled deletion time.
- $initialDelete = Piwik_GetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL);
+ $initialDelete = Option::get(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL);
if (empty($initialDelete)) {
- Piwik_SetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
+ Option::set(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
return false;
}
// Make sure, log purging is allowed to run now
- $lastDelete = Piwik_GetOption($lastRanOption);
+ $lastDelete = Option::get($lastRanOption);
$deleteIntervalDays = $settings['delete_logs_schedule_lowest_interval'];
$deleteIntervalSeconds = $this->getDeleteIntervalInSeconds($deleteIntervalDays);
diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php
index 00ba33b32f..6c6dab9f54 100644
--- a/plugins/SitesManager/API.php
+++ b/plugins/SitesManager/API.php
@@ -17,6 +17,7 @@ use Piwik\Date;
use Piwik\Db;
use Piwik\IP;
use Piwik\MetricsFormatter;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\SettingsPiwik;
use Piwik\SettingsServer;
@@ -714,7 +715,7 @@ class API
{
Piwik::checkUserIsSuperUser();
$excludedIps = $this->checkAndReturnExcludedIps($excludedIps);
- Piwik_SetOption(self::OPTION_EXCLUDED_IPS_GLOBAL, $excludedIps);
+ Option::set(self::OPTION_EXCLUDED_IPS_GLOBAL, $excludedIps);
Cache::deleteTrackerCache();
return true;
}
@@ -730,8 +731,8 @@ class API
public function setGlobalSearchParameters($searchKeywordParameters, $searchCategoryParameters)
{
Piwik::checkUserIsSuperUser();
- Piwik_SetOption(self::OPTION_SEARCH_KEYWORD_QUERY_PARAMETERS_GLOBAL, $searchKeywordParameters);
- Piwik_SetOption(self::OPTION_SEARCH_CATEGORY_QUERY_PARAMETERS_GLOBAL, $searchCategoryParameters);
+ Option::set(self::OPTION_SEARCH_KEYWORD_QUERY_PARAMETERS_GLOBAL, $searchKeywordParameters);
+ Option::set(self::OPTION_SEARCH_CATEGORY_QUERY_PARAMETERS_GLOBAL, $searchCategoryParameters);
Cache::deleteTrackerCache();
return true;
}
@@ -742,7 +743,7 @@ class API
public function getSearchKeywordParametersGlobal()
{
Piwik::checkUserHasSomeAdminAccess();
- $names = Piwik_GetOption(self::OPTION_SEARCH_KEYWORD_QUERY_PARAMETERS_GLOBAL);
+ $names = Option::get(self::OPTION_SEARCH_KEYWORD_QUERY_PARAMETERS_GLOBAL);
if ($names === false) {
$names = self::DEFAULT_SEARCH_KEYWORD_PARAMETERS;
}
@@ -758,7 +759,7 @@ class API
public function getSearchCategoryParametersGlobal()
{
Piwik::checkUserHasSomeAdminAccess();
- return Piwik_GetOption(self::OPTION_SEARCH_CATEGORY_QUERY_PARAMETERS_GLOBAL);
+ return Option::get(self::OPTION_SEARCH_CATEGORY_QUERY_PARAMETERS_GLOBAL);
}
/**
@@ -769,7 +770,7 @@ class API
public function getExcludedQueryParametersGlobal()
{
Piwik::checkUserHasSomeViewAccess();
- return Piwik_GetOption(self::OPTION_EXCLUDED_QUERY_PARAMETERS_GLOBAL);
+ return Option::get(self::OPTION_EXCLUDED_QUERY_PARAMETERS_GLOBAL);
}
/**
@@ -782,7 +783,7 @@ class API
public function getExcludedUserAgentsGlobal()
{
Piwik::checkUserHasSomeAdminAccess();
- return Piwik_GetOption(self::OPTION_EXCLUDED_USER_AGENTS_GLOBAL);
+ return Option::get(self::OPTION_EXCLUDED_USER_AGENTS_GLOBAL);
}
/**
@@ -798,7 +799,7 @@ class API
// update option
$excludedUserAgents = $this->checkAndReturnCommaSeparatedStringList($excludedUserAgents);
- Piwik_SetOption(self::OPTION_EXCLUDED_USER_AGENTS_GLOBAL, $excludedUserAgents);
+ Option::set(self::OPTION_EXCLUDED_USER_AGENTS_GLOBAL, $excludedUserAgents);
// make sure tracker cache will reflect change
Cache::deleteTrackerCache();
@@ -813,7 +814,7 @@ class API
public function isSiteSpecificUserAgentExcludeEnabled()
{
Piwik::checkUserHasSomeAdminAccess();
- return (bool)Piwik_GetOption(self::OPTION_SITE_SPECIFIC_USER_AGENT_EXCLUDE_ENABLE);
+ return (bool)Option::get(self::OPTION_SITE_SPECIFIC_USER_AGENT_EXCLUDE_ENABLE);
}
/**
@@ -827,7 +828,7 @@ class API
Piwik::checkUserIsSuperUser();
// update option
- Piwik_SetOption(self::OPTION_SITE_SPECIFIC_USER_AGENT_EXCLUDE_ENABLE, $enabled);
+ Option::set(self::OPTION_SITE_SPECIFIC_USER_AGENT_EXCLUDE_ENABLE, $enabled);
// make sure tracker cache will reflect change
Cache::deleteTrackerCache();
@@ -842,7 +843,7 @@ class API
public function getKeepURLFragmentsGlobal()
{
Piwik::checkUserHasSomeViewAccess();
- return (bool)Piwik_GetOption(self::OPTION_KEEP_URL_FRAGMENTS_GLOBAL);
+ return (bool)Option::get(self::OPTION_KEEP_URL_FRAGMENTS_GLOBAL);
}
/**
@@ -858,7 +859,7 @@ class API
Piwik::checkUserIsSuperUser();
// update option
- Piwik_SetOption(self::OPTION_KEEP_URL_FRAGMENTS_GLOBAL, $enabled);
+ Option::set(self::OPTION_KEEP_URL_FRAGMENTS_GLOBAL, $enabled);
// make sure tracker cache will reflect change
Cache::deleteTrackerCache();
@@ -875,7 +876,7 @@ class API
{
Piwik::checkUserIsSuperUser();
$excludedQueryParameters = $this->checkAndReturnCommaSeparatedStringList($excludedQueryParameters);
- Piwik_SetOption(self::OPTION_EXCLUDED_QUERY_PARAMETERS_GLOBAL, $excludedQueryParameters);
+ Option::set(self::OPTION_EXCLUDED_QUERY_PARAMETERS_GLOBAL, $excludedQueryParameters);
Cache::deleteTrackerCache();
return true;
}
@@ -888,7 +889,7 @@ class API
public function getExcludedIpsGlobal()
{
Piwik::checkUserHasSomeAdminAccess();
- return Piwik_GetOption(self::OPTION_EXCLUDED_IPS_GLOBAL);
+ return Option::get(self::OPTION_EXCLUDED_IPS_GLOBAL);
}
/**
@@ -899,7 +900,7 @@ class API
public function getDefaultCurrency()
{
Piwik::checkUserHasSomeAdminAccess();
- $defaultCurrency = Piwik_GetOption(self::OPTION_DEFAULT_CURRENCY);
+ $defaultCurrency = Option::get(self::OPTION_DEFAULT_CURRENCY);
if ($defaultCurrency) {
return $defaultCurrency;
}
@@ -916,7 +917,7 @@ class API
{
Piwik::checkUserIsSuperUser();
$this->checkValidCurrency($defaultCurrency);
- Piwik_SetOption(self::OPTION_DEFAULT_CURRENCY, $defaultCurrency);
+ Option::set(self::OPTION_DEFAULT_CURRENCY, $defaultCurrency);
return true;
}
@@ -928,7 +929,7 @@ class API
*/
public function getDefaultTimezone()
{
- $defaultTimezone = Piwik_GetOption(self::OPTION_DEFAULT_TIMEZONE);
+ $defaultTimezone = Option::get(self::OPTION_DEFAULT_TIMEZONE);
if ($defaultTimezone) {
return $defaultTimezone;
}
@@ -945,7 +946,7 @@ class API
{
Piwik::checkUserIsSuperUser();
$this->checkValidTimezone($defaultTimezone);
- Piwik_SetOption(self::OPTION_DEFAULT_TIMEZONE, $defaultTimezone);
+ Option::set(self::OPTION_DEFAULT_TIMEZONE, $defaultTimezone);
return true;
}
diff --git a/plugins/UserCountry/GeoIPAutoUpdater.php b/plugins/UserCountry/GeoIPAutoUpdater.php
index ec1627a5fb..8a8064db57 100755
--- a/plugins/UserCountry/GeoIPAutoUpdater.php
+++ b/plugins/UserCountry/GeoIPAutoUpdater.php
@@ -15,6 +15,7 @@ use Piwik\Common;
use Piwik\Date;
use Piwik\Http;
use Piwik\Log;
+use Piwik\Option;
use Piwik\Plugins\UserCountry\LocationProvider;
use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Php;
@@ -60,19 +61,19 @@ class GeoIPAutoUpdater
public function update()
{
try {
- Piwik_SetOption(self::LAST_RUN_TIME_OPTION_NAME, Date::factory('today')->getTimestamp());
+ Option::set(self::LAST_RUN_TIME_OPTION_NAME, Date::factory('today')->getTimestamp());
- $locUrl = Piwik_GetOption(self::LOC_URL_OPTION_NAME);
+ $locUrl = Option::get(self::LOC_URL_OPTION_NAME);
if (!empty($locUrl)) {
$this->downloadFile('loc', $locUrl);
}
- $ispUrl = Piwik_GetOption(self::ISP_URL_OPTION_NAME);
+ $ispUrl = Option::get(self::ISP_URL_OPTION_NAME);
if (!empty($ispUrl)) {
$this->downloadFile('isp', $ispUrl);
}
- $orgUrl = Piwik_GetOption(self::ORG_URL_OPTION_NAME);
+ $orgUrl = Option::get(self::ORG_URL_OPTION_NAME);
if (!empty($orgUrl)) {
$this->downloadFile('org', $orgUrl);
}
@@ -324,7 +325,7 @@ class GeoIPAutoUpdater
$url = $options[$optionKey];
$url = self::removeDateFromUrl($url);
- Piwik_SetOption($optionName, $url);
+ Option::set($optionName, $url);
}
// set period option
@@ -339,7 +340,7 @@ class GeoIPAutoUpdater
));
}
- Piwik_SetOption(self::SCHEDULE_PERIOD_OPTION_NAME, $period);
+ Option::set(self::SCHEDULE_PERIOD_OPTION_NAME, $period);
}
}
@@ -351,9 +352,9 @@ class GeoIPAutoUpdater
*/
public static function isUpdaterSetup()
{
- if (Piwik_GetOption(self::LOC_URL_OPTION_NAME) !== false
- || Piwik_GetOption(self::ISP_URL_OPTION_NAME) !== false
- || Piwik_GetOption(self::ORG_URL_OPTION_NAME) !== false
+ if (Option::get(self::LOC_URL_OPTION_NAME) !== false
+ || Option::get(self::ISP_URL_OPTION_NAME) !== false
+ || Option::get(self::ORG_URL_OPTION_NAME) !== false
) {
return true;
}
@@ -370,7 +371,7 @@ class GeoIPAutoUpdater
{
$result = array();
foreach (self::$urlOptions as $key => $optionName) {
- $result[$key] = Piwik_GetOption($optionName);
+ $result[$key] = Option::get($optionName);
}
return $result;
}
@@ -387,7 +388,7 @@ class GeoIPAutoUpdater
if (empty(self::$urlOptions[$key])) {
throw new Exception("Invalid key $key");
}
- $url = Piwik_GetOption(self::$urlOptions[$key]);
+ $url = Option::get(self::$urlOptions[$key]);
return $url;
}
@@ -408,7 +409,7 @@ class GeoIPAutoUpdater
*/
public static function getSchedulePeriod()
{
- $period = Piwik_GetOption(self::SCHEDULE_PERIOD_OPTION_NAME);
+ $period = Option::get(self::SCHEDULE_PERIOD_OPTION_NAME);
if ($period === false) {
$period = self::SCHEDULE_PERIOD_MONTHLY;
}
@@ -598,7 +599,7 @@ class GeoIPAutoUpdater
*/
public static function getLastRunTime()
{
- $timestamp = Piwik_GetOption(self::LAST_RUN_TIME_OPTION_NAME);
+ $timestamp = Option::get(self::LAST_RUN_TIME_OPTION_NAME);
return $timestamp === false ? false : Date::factory((int)$timestamp);
}
diff --git a/plugins/UserCountry/LocationProvider.php b/plugins/UserCountry/LocationProvider.php
index 554ee735d3..23d3f47a24 100755
--- a/plugins/UserCountry/LocationProvider.php
+++ b/plugins/UserCountry/LocationProvider.php
@@ -13,6 +13,7 @@ namespace Piwik\Plugins\UserCountry;
use Exception;
use Piwik\Common;
use Piwik\IP;
+use Piwik\Option;
use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider;
use Piwik\Tracker\Cache;
use ReflectionClass;
@@ -263,7 +264,7 @@ abstract class LocationProvider
*/
public static function getCurrentProviderId()
{
- $optionValue = Piwik_GetOption(self::CURRENT_PROVIDER_OPTION_NAME);
+ $optionValue = Option::get(self::CURRENT_PROVIDER_OPTION_NAME);
return $optionValue === false ? DefaultProvider::ID : $optionValue;
}
@@ -293,7 +294,7 @@ abstract class LocationProvider
throw new Exception(
"Invalid provider ID '$providerId'. The provider either does not exist or is not available");
}
- Piwik_SetOption(self::CURRENT_PROVIDER_OPTION_NAME, $providerId);
+ Option::set(self::CURRENT_PROVIDER_OPTION_NAME, $providerId);
Cache::clearCacheGeneral();
return $provider;
}
diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php
index 12a246b5a2..47217e73b1 100644
--- a/plugins/UsersManager/API.php
+++ b/plugins/UsersManager/API.php
@@ -16,6 +16,7 @@ use Piwik\Common;
use Piwik\Config;
use Piwik\Date;
use Piwik\Db;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Site;
use Piwik\Tracker\Cache;
@@ -76,7 +77,7 @@ class API
public function setUserPreference($userLogin, $preferenceName, $preferenceValue)
{
Piwik::checkUserIsSuperUserOrTheUser($userLogin);
- Piwik_SetOption($this->getPreferenceId($userLogin, $preferenceName), $preferenceValue);
+ Option::set($this->getPreferenceId($userLogin, $preferenceName), $preferenceValue);
}
/**
@@ -89,7 +90,7 @@ class API
{
Piwik::checkUserIsSuperUserOrTheUser($userLogin);
- $optionValue = Piwik_GetOption($this->getPreferenceId($userLogin, $preferenceName));
+ $optionValue = Option::get($this->getPreferenceId($userLogin, $preferenceName));
if ($optionValue !== false) {
return $optionValue;
}
diff --git a/plugins/UsersManager/UsersManager.php b/plugins/UsersManager/UsersManager.php
index 3193315e1e..4f4ff6bfde 100644
--- a/plugins/UsersManager/UsersManager.php
+++ b/plugins/UsersManager/UsersManager.php
@@ -66,7 +66,7 @@ class UsersManager extends \Piwik\Plugin
*/
public function deleteSite($idSite)
{
- Option::getInstance()->deleteLike('%\_' . API::PREFERENCE_DEFAULT_REPORT, $idSite);
+ Option::deleteLike('%\_' . API::PREFERENCE_DEFAULT_REPORT, $idSite);
}
/**
diff --git a/tests/PHPUnit/BenchmarkTestCase.php b/tests/PHPUnit/BenchmarkTestCase.php
index 42b54260e6..2152ccb583 100755
--- a/tests/PHPUnit/BenchmarkTestCase.php
+++ b/tests/PHPUnit/BenchmarkTestCase.php
@@ -53,7 +53,7 @@ abstract class BenchmarkTestCase extends IntegrationTestCase
}
Db::query("USE " . $dbName);
- $installedFixture = Piwik_GetOption('benchmark_fixture_name');
+ $installedFixture = \Piwik\Option::get('benchmark_fixture_name');
} catch (Exception $ex) {
// ignore
}
@@ -64,7 +64,7 @@ abstract class BenchmarkTestCase extends IntegrationTestCase
// if we created an empty database, setup the fixture
if ($createEmptyDatabase) {
self::$fixture->setUp();
- Piwik_SetOption('benchmark_fixture_name', $fixtureName);
+ \Piwik\Option::set('benchmark_fixture_name', $fixtureName);
}
}
diff --git a/tests/PHPUnit/Core/OptionTest.php b/tests/PHPUnit/Core/OptionTest.php
index e921a38ad9..f6bd624d60 100644
--- a/tests/PHPUnit/Core/OptionTest.php
+++ b/tests/PHPUnit/Core/OptionTest.php
@@ -20,19 +20,19 @@ class OptionTest extends DatabaseTestCase
public function testGet()
{
// empty table, expect false (i.e., not found)
- $this->assertFalse(Option::getInstance()->get('anonymous_defaultReport'));
+ $this->assertFalse(Option::get('anonymous_defaultReport'));
// populate table, expect '1' (i.e., found)
Db::query("INSERT INTO " . Common::prefixTable('option') . " VALUES ('anonymous_defaultReport', '1', false)");
- $this->assertSame('1', Option::getInstance()->get('anonymous_defaultReport'));
+ $this->assertSame('1', Option::get('anonymous_defaultReport'));
// delete row (bypassing API), expect '1' (i.e., from cache)
Db::query("DELETE FROM " . Common::prefixTable('option') . " WHERE option_name = ?", array('anonymous_defaultReport'));
- $this->assertSame('1', Option::getInstance()->get('anonymous_defaultReport'));
+ $this->assertSame('1', Option::get('anonymous_defaultReport'));
// force cache reload, expect false (i.e., not found)
- Option::getInstance()->clearCache();
- $this->assertFalse(Option::getInstance()->get('anonymous_defaultReport'));
+ Option::clearCache();
+ $this->assertFalse(Option::get('anonymous_defaultReport'));
}
/**
@@ -42,19 +42,19 @@ class OptionTest extends DatabaseTestCase
public function testGetOption()
{
// empty table, expect false (i.e., not found)
- $this->assertFalse(Piwik_GetOption('anonymous_defaultReport'));
+ $this->assertFalse(Option::get('anonymous_defaultReport'));
// populate table, expect '1' (i.e., found)
Db::query("INSERT INTO " . Common::prefixTable('option') . " VALUES ('anonymous_defaultReport', '1',true)");
- $this->assertSame('1', Piwik_GetOption('anonymous_defaultReport'));
+ $this->assertSame('1', Option::get('anonymous_defaultReport'));
// delete row (bypassing API), expect '1' (i.e., from cache)
Db::query("DELETE FROM " . Common::prefixTable('option') . " WHERE option_name = ?", array('anonymous_defaultReport'));
- $this->assertSame('1', Piwik_GetOption('anonymous_defaultReport'));
+ $this->assertSame('1', Option::get('anonymous_defaultReport'));
// force cache reload, expect false (i.e., not found)
- Option::getInstance()->clearCache();
- $this->assertFalse(Piwik_GetOption('anonymous_defaultReport'));
+ Option::clearCache();
+ $this->assertFalse(Option::get('anonymous_defaultReport'));
}
/**
@@ -64,11 +64,11 @@ class OptionTest extends DatabaseTestCase
public function testSet()
{
// empty table, expect false (i.e., not found)
- $this->assertFalse(Piwik_GetOption('anonymous_defaultReport'));
+ $this->assertFalse(Option::get('anonymous_defaultReport'));
// populate table, expect '1'
- Option::getInstance()->set('anonymous_defaultReport', '1', true);
- $this->assertSame('1', Option::getInstance()->get('anonymous_defaultReport'));
+ Option::set('anonymous_defaultReport', '1', true);
+ $this->assertSame('1', Option::get('anonymous_defaultReport'));
}
/**
@@ -78,11 +78,11 @@ class OptionTest extends DatabaseTestCase
public function testSetOption()
{
// empty table, expect false (i.e., not found)
- $this->assertFalse(Piwik_GetOption('anonymous_defaultReport'));
+ $this->assertFalse(Option::get('anonymous_defaultReport'));
// populate table, expect '1'
- Piwik_SetOption('anonymous_defaultReport', '1', false);
- $this->assertSame('1', Option::getInstance()->get('anonymous_defaultReport'));
+ Option::set('anonymous_defaultReport', '1', false);
+ $this->assertSame('1', Option::get('anonymous_defaultReport'));
}
/**
@@ -92,33 +92,33 @@ class OptionTest extends DatabaseTestCase
public function testDelete()
{
// empty table, expect false (i.e., not found)
- $this->assertFalse(Piwik_GetOption('anonymous_defaultReport'));
- $this->assertFalse(Piwik_GetOption('admin_defaultReport'));
+ $this->assertFalse(Option::get('anonymous_defaultReport'));
+ $this->assertFalse(Option::get('admin_defaultReport'));
// populate table, expect '1'
- Piwik_SetOption('anonymous_defaultReport', '1', true);
- Option::getInstance()->delete('_defaultReport');
- $this->assertSame('1', Option::getInstance()->get('anonymous_defaultReport'));
+ Option::set('anonymous_defaultReport', '1', true);
+ Option::delete('_defaultReport');
+ $this->assertSame('1', Option::get('anonymous_defaultReport'));
// populate table, expect '2'
- Piwik_SetOption('admin_defaultReport', '2', false);
- Option::getInstance()->delete('_defaultReport');
- $this->assertSame('2', Option::getInstance()->get('admin_defaultReport'));
+ Option::set('admin_defaultReport', '2', false);
+ Option::delete('_defaultReport');
+ $this->assertSame('2', Option::get('admin_defaultReport'));
// delete with non-matching value, expect '1'
- Option::getInstance()->delete('anonymous_defaultReport', '2');
- $this->assertSame('1', Option::getInstance()->get('anonymous_defaultReport'));
+ Option::delete('anonymous_defaultReport', '2');
+ $this->assertSame('1', Option::get('anonymous_defaultReport'));
// delete with matching value, expect false
- Option::getInstance()->delete('anonymous_defaultReport', '1');
- $this->assertFalse(Option::getInstance()->get('anonymous_defaultReport'));
+ Option::delete('anonymous_defaultReport', '1');
+ $this->assertFalse(Option::get('anonymous_defaultReport'));
// this shouldn't have been deleted, expect '2'
- $this->assertSame('2', Option::getInstance()->get('admin_defaultReport'));
+ $this->assertSame('2', Option::get('admin_defaultReport'));
// deleted, expect false
- Option::getInstance()->delete('admin_defaultReport');
- $this->assertFalse(Option::getInstance()->get('admin_defaultReport'));
+ Option::delete('admin_defaultReport');
+ $this->assertFalse(Option::get('admin_defaultReport'));
}
/**
@@ -128,66 +128,66 @@ class OptionTest extends DatabaseTestCase
public function testDeleteLike()
{
// empty table, expect false (i.e., not found)
- $this->assertFalse(Piwik_GetOption('anonymous_defaultReport'));
- $this->assertFalse(Piwik_GetOption('admin_defaultReport'));
- $this->assertFalse(Piwik_GetOption('visitor_defaultReport'));
+ $this->assertFalse(Option::get('anonymous_defaultReport'));
+ $this->assertFalse(Option::get('admin_defaultReport'));
+ $this->assertFalse(Option::get('visitor_defaultReport'));
// insert guard - to test unescaped underscore
- Piwik_SetOption('adefaultReport', '0', true);
- $this->assertTrue(Piwik_GetOption('adefaultReport') === '0');
+ Option::set('adefaultReport', '0', true);
+ $this->assertTrue(Option::get('adefaultReport') === '0');
// populate table, expect '1'
- Piwik_SetOption('anonymous_defaultReport', '1', true);
- Option::getInstance()->deleteLike('\_defaultReport');
- $this->assertSame('1', Option::getInstance()->get('anonymous_defaultReport'));
- $this->assertSame('0', Piwik_GetOption('adefaultReport'));
+ Option::set('anonymous_defaultReport', '1', true);
+ Option::deleteLike('\_defaultReport');
+ $this->assertSame('1', Option::get('anonymous_defaultReport'));
+ $this->assertSame('0', Option::get('adefaultReport'));
// populate table, expect '2'
- Piwik_SetOption('admin_defaultReport', '2', false);
- Option::getInstance()->deleteLike('\_defaultReport');
- $this->assertSame('2', Option::getInstance()->get('admin_defaultReport'));
- $this->assertSame('0', Piwik_GetOption('adefaultReport'));
+ Option::set('admin_defaultReport', '2', false);
+ Option::deleteLike('\_defaultReport');
+ $this->assertSame('2', Option::get('admin_defaultReport'));
+ $this->assertSame('0', Option::get('adefaultReport'));
// populate table, expect '3'
- Piwik_SetOption('visitor_defaultReport', '3', false);
- Option::getInstance()->deleteLike('\_defaultReport');
- $this->assertSame('3', Option::getInstance()->get('visitor_defaultReport'));
- $this->assertSame('0', Piwik_GetOption('adefaultReport'));
+ Option::set('visitor_defaultReport', '3', false);
+ Option::deleteLike('\_defaultReport');
+ $this->assertSame('3', Option::get('visitor_defaultReport'));
+ $this->assertSame('0', Option::get('adefaultReport'));
// delete with non-matching value, expect '1'
- Option::getInstance()->deleteLike('%\_defaultReport', '4');
- $this->assertSame('1', Option::getInstance()->get('anonymous_defaultReport'));
- $this->assertSame('0', Piwik_GetOption('adefaultReport'));
+ Option::deleteLike('%\_defaultReport', '4');
+ $this->assertSame('1', Option::get('anonymous_defaultReport'));
+ $this->assertSame('0', Option::get('adefaultReport'));
// delete with matching pattern, expect false
- Option::getInstance()->deleteLike('%\_defaultReport', '1');
- $this->assertFalse(Option::getInstance()->get('anonymous_defaultReport'));
- $this->assertSame('0', Piwik_GetOption('adefaultReport'));
+ Option::deleteLike('%\_defaultReport', '1');
+ $this->assertFalse(Option::get('anonymous_defaultReport'));
+ $this->assertSame('0', Option::get('adefaultReport'));
// this shouldn't have been deleted, expect '2' and '3'
- $this->assertSame('2', Option::getInstance()->get('admin_defaultReport'));
- $this->assertSame('3', Option::getInstance()->get('visitor_defaultReport'));
- $this->assertSame('0', Piwik_GetOption('adefaultReport'));
+ $this->assertSame('2', Option::get('admin_defaultReport'));
+ $this->assertSame('3', Option::get('visitor_defaultReport'));
+ $this->assertSame('0', Option::get('adefaultReport'));
// deleted, expect false (except for the guard)
- Option::getInstance()->deleteLike('%\_defaultReport');
- $this->assertFalse(Option::getInstance()->get('admin_defaultReport'));
- $this->assertFalse(Option::getInstance()->get('visitor_defaultReport'));
+ Option::deleteLike('%\_defaultReport');
+ $this->assertFalse(Option::get('admin_defaultReport'));
+ $this->assertFalse(Option::get('visitor_defaultReport'));
// unescaped backslash (single quotes)
- Option::getInstance()->deleteLike('%\_defaultReport');
- $this->assertSame('0', Piwik_GetOption('adefaultReport'));
+ Option::deleteLike('%\_defaultReport');
+ $this->assertSame('0', Option::get('adefaultReport'));
// escaped backslash (single quotes)
- Option::getInstance()->deleteLike('%\\_defaultReport');
- $this->assertSame('0', Piwik_GetOption('adefaultReport'));
+ Option::deleteLike('%\\_defaultReport');
+ $this->assertSame('0', Option::get('adefaultReport'));
// unescaped backslash (double quotes)
- Option::getInstance()->deleteLike("%\_defaultReport");
- $this->assertSame('0', Piwik_GetOption('adefaultReport'));
+ Option::deleteLike("%\_defaultReport");
+ $this->assertSame('0', Option::get('adefaultReport'));
// escaped backslash (double quotes)
- Option::getInstance()->deleteLike("%\\_defaultReport");
- $this->assertSame('0', Piwik_GetOption('adefaultReport'));
+ Option::deleteLike("%\\_defaultReport");
+ $this->assertSame('0', Option::get('adefaultReport'));
}
}
diff --git a/tests/PHPUnit/DatabaseTestCase.php b/tests/PHPUnit/DatabaseTestCase.php
index 1f5a2507fb..4b2fe845c0 100644
--- a/tests/PHPUnit/DatabaseTestCase.php
+++ b/tests/PHPUnit/DatabaseTestCase.php
@@ -71,7 +71,7 @@ class DatabaseTestCase extends PHPUnit_Framework_TestCase
IntegrationTestCase::unloadAllPlugins();
DbHelper::dropDatabase();
Manager::getInstance()->deleteAll();
- Option::getInstance()->clearCache();
+ Option::clearCache();
API::$cache = array();
Site::clearCache();
Cache::deleteTrackerCache();
diff --git a/tests/PHPUnit/Integration/ArchiveCronTest.php b/tests/PHPUnit/Integration/ArchiveCronTest.php
index 2464d59fad..aa5eec7787 100644
--- a/tests/PHPUnit/Integration/ArchiveCronTest.php
+++ b/tests/PHPUnit/Integration/ArchiveCronTest.php
@@ -100,7 +100,7 @@ class Test_Piwik_Integration_ArchiveCronTest extends IntegrationTestCase
// lastRunKey() function inlined
$lastRunArchiveOption = "lastRunArchive" . $period . "_" . $idSite;
- Piwik_SetOption($lastRunArchiveOption, $time);
+ \Piwik\Option::set($lastRunArchiveOption, $time);
}
}
}
diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php
index 799ad6eaa3..4170b6abae 100755
--- a/tests/PHPUnit/IntegrationTestCase.php
+++ b/tests/PHPUnit/IntegrationTestCase.php
@@ -233,7 +233,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
DbHelper::dropDatabase();
}
Manager::getInstance()->deleteAll();
- Option::getInstance()->clearCache();
+ Option::clearCache();
Site::clearCache();
Cache::deleteTrackerCache();
Config::getInstance()->clear();
diff --git a/tests/PHPUnit/MockPiwikOption.php b/tests/PHPUnit/MockPiwikOption.php
index 530a84a777..aa7d4391f0 100644
--- a/tests/PHPUnit/MockPiwikOption.php
+++ b/tests/PHPUnit/MockPiwikOption.php
@@ -9,20 +9,20 @@ use Piwik\Option;
class MockPiwikOption extends Option
{
- private $forcedOptionValue = false;
+ private static $forcedOptionValue = false;
function __construct($forcedOptionValue)
{
- $this->forcedOptionValue = $forcedOptionValue;
+ self::$forcedOptionValue = $forcedOptionValue;
}
- public function get($name)
+ public static function get($name)
{
- return $this->forcedOptionValue;
+ return self::$forcedOptionValue;
}
- public function set($name, $value, $autoLoad = 0)
+ public static function set($name, $value, $autoLoad = 0)
{
- $this->forcedOptionValue = $value;
+ self::$forcedOptionValue = $value;
}
}
diff --git a/tests/PHPUnit/Plugins/PrivacyManagerTest.php b/tests/PHPUnit/Plugins/PrivacyManagerTest.php
index 09fec4a10e..9f19f42052 100755
--- a/tests/PHPUnit/Plugins/PrivacyManagerTest.php
+++ b/tests/PHPUnit/Plugins/PrivacyManagerTest.php
@@ -121,7 +121,7 @@ class PrivacyManagerTest extends IntegrationTestCase
{
parent::tearDown();
Manager::getInstance()->deleteAll();
- Option::getInstance()->clearCache();
+ Option::clearCache();
Site::clearCache();
Cache::deleteTrackerCache();
ArchiveTableCreator::clear();
@@ -142,7 +142,7 @@ class PrivacyManagerTest extends IntegrationTestCase
// check that initial option is set
$this->assertEquals(
- 1, Piwik_GetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL));
+ 1, Option::get(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL));
// perform other checks
$this->_checkNoDataChanges();
@@ -159,7 +159,7 @@ class PrivacyManagerTest extends IntegrationTestCase
$this->instance->deleteReportData();
// check that initial option is set
- $this->assertEquals(1, Piwik_GetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL));
+ $this->assertEquals(1, Option::get(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL));
// perform other checks
$this->_checkNoDataChanges();
@@ -175,9 +175,9 @@ class PrivacyManagerTest extends IntegrationTestCase
{
$yesterdaySecs = Date::factory('yesterday')->getTimestamp();
- Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
- Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS, $yesterdaySecs);
- Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_REPORTS, $yesterdaySecs);
+ Option::set(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
+ Option::set(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS, $yesterdaySecs);
+ Option::set(PrivacyManager::OPTION_LAST_DELETE_PIWIK_REPORTS, $yesterdaySecs);
$this->instance->deleteLogData();
$this->instance->deleteReportData();
@@ -849,9 +849,9 @@ class PrivacyManagerTest extends IntegrationTestCase
{
$lastDateSecs = Date::factory('today')->subDay(8)->getTimestamp();
- Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
- Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDateSecs);
- Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_REPORTS, $lastDateSecs);
+ Option::set(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
+ Option::set(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDateSecs);
+ Option::set(PrivacyManager::OPTION_LAST_DELETE_PIWIK_REPORTS, $lastDateSecs);
}
protected function _getTableCount($tableName, $where = '')
diff --git a/tests/PHPUnit/proxy/piwik.php b/tests/PHPUnit/proxy/piwik.php
index 977a490394..8d68aacb97 100755
--- a/tests/PHPUnit/proxy/piwik.php
+++ b/tests/PHPUnit/proxy/piwik.php
@@ -44,7 +44,7 @@ GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
Tracker::setTestEnvironment();
Manager::getInstance()->deleteAll();
-Option::getInstance()->clearCache();
+Option::clearCache();
Site::clearCache();
Cache::deleteTrackerCache();