diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-04-04 07:24:45 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-04-04 07:24:45 +0400 |
commit | 2739eeec2ffd189873d706317a4ba11fc9b04453 (patch) | |
tree | 102dc7a10dcbe1d3ed708a02fd79778f068e02e8 /core | |
parent | 7143784693cca662fb856a1e2dd4aa055c3b6daa (diff) |
Removing the SettingsPiwik::$piwikUrlCache hack, ftw?
Diffstat (limited to 'core')
-rw-r--r-- | core/SettingsPiwik.php | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php index 4c8bcaea70..f21e1c3328 100644 --- a/core/SettingsPiwik.php +++ b/core/SettingsPiwik.php @@ -16,6 +16,7 @@ use Exception; */ class SettingsPiwik { + const OPTION_PIWIK_URL = 'piwikUrl'; /** * Get salt from [General] section * @@ -147,14 +148,6 @@ class SettingsPiwik } /** - * Cache for result of getPiwikUrl. - * Can be overwritten for testing purposes only. - * - * @var string - */ - static public $piwikUrlCache = null; - - /** * Returns the URL to this Piwik instance, eg. **http://demo.piwik.org/** or **http://example.org/piwik/**. * * @return string @@ -162,13 +155,7 @@ class SettingsPiwik */ public static function getPiwikUrl() { - // Only set in tests - if (self::$piwikUrlCache !== null) { - return self::$piwikUrlCache; - } - - $key = 'piwikUrl'; - $url = Option::get($key); + $url = Option::get(self::OPTION_PIWIK_URL); $isPiwikCoreDispatching = defined('PIWIK_ENABLE_DISPATCH') && PIWIK_ENABLE_DISPATCH; if (Common::isPhpCliMode() @@ -187,7 +174,7 @@ class SettingsPiwik || $currentUrl != $url ) { if (strlen($currentUrl) >= strlen('http://a/')) { - Option::set($key, $currentUrl, $autoLoad = true); + self::overwritePiwikUrl($currentUrl); } $url = $currentUrl; } @@ -357,4 +344,12 @@ class SettingsPiwik return $configByHost; } + /** + * @param $currentUrl + */ + public static function overwritePiwikUrl($currentUrl) + { + Option::set(self::OPTION_PIWIK_URL, $currentUrl, $autoLoad = true); + } + } |