Skip to content
Extraits de code Groupes Projets
Valider f3301e8f rédigé par Benaka Moorthi's avatar Benaka Moorthi
Parcourir les fichiers

Removed the deprecated Piwik_Config_Compat file and the Piwik::createConfigObject function.

parent 61ac0ef4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -51,6 +51,7 @@ class Piwik_Config
{
if (self::$instance == null) {
self::$instance = new self;
self::$instance->init();
}
return self::$instance;
}
......
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik
* @package Piwik
*/
/**
* Backward compatibility ayer
*
* @todo remove this in 2.0
* @since 1.7
* @deprecated 1.7
* @see Piwik::createConfigObject()
*
* @package Piwik
* @subpackage Piwik_Config
*/
class Piwik_Config_Compat_Array
{
private $data;
/**
* @var Piwik_Config_Compat
*/
private $parent;
/**
* Constructor
*
* @param Piwik_Config_Compat $parent
* @param array $data configuration section
*/
public function __construct($parent, array $data)
{
$this->parent = $parent;
$this->data = $data;
}
/**
* Get value by name
*
* @param string $name
* @return mixed
*/
public function __get($name)
{
$tmp = isset($this->data[$name]) ? $this->data[$name] : false;
return is_array($tmp) ? new Piwik_Config_Compat_Array($this, $tmp) : $tmp;
}
/**
* Set name, value pair
*
* @param string $name
* @param mixed $value
*/
public function __set($name, $value)
{
if (is_object($value) && get_class($value) == 'Piwik_Config_Compat_Array') {
$value = $value->toArray();
}
$this->data[$name] = $value;
$this->setDirtyBit();
}
/**
* Convert object to array
*
* @return array
*/
public function toArray()
{
return $this->data;
}
/**
* Set dirty bit
*/
public function setDirtyBit()
{
$this->parent->setDirtyBit();
}
}
class Piwik_Config_Compat
{
private $config;
private $data;
private $enabled;
private $dirty;
/**
* Constructor
*/
public function __construct()
{
$this->config = Piwik_Config::getInstance();
$this->data = array();
$this->enabled = true;
$this->dirty = false;
}
/**
* Destructor
*/
public function __destruct()
{
if ($this->enabled && $this->dirty) {
$this->config->forceSave();
}
$this->config->clear();
}
/**
* Get value by name
*
* @param string $name
* @return mixed
*/
public function __get($name)
{
if (!isset($this->data[$name])) {
$this->data[$name] = $this->config->__get($name);
}
$tmp = $this->data[$name];
return is_array($tmp) ? new Piwik_Config_Compat_Array($this, $tmp) : $tmp;
}
/**
* Set name, value pair
*
* @param string $name
* @param mixed $value
*/
public function __set($name, $value)
{
if (is_object($value) && get_class($value) == 'Piwik_Config_Compat_Array') {
$value = $value->toArray();
}
$this->config->__set($name, $value);
$this->dirty = true;
}
/**
* Set dirty bit
*/
public function setDirtyBit()
{
$this->dirty = true;
}
/**
* Disable saving of configuration changes
*/
public function disableSavingConfigurationFileUpdates()
{
$this->enabled = false;
}
}
......@@ -189,7 +189,7 @@ class Piwik_FrontController
{
$exceptionToThrow = false;
try {
Piwik::createConfigObject();
Piwik_Config::getInstance();
} catch (Exception $e) {
Piwik_PostEvent('FrontController.NoConfigurationFile', array($e), $pending = true);
$exceptionToThrow = $e;
......
......@@ -2002,23 +2002,6 @@ class Piwik
}
}
/*
* Global config object
*/
/**
* Create configuration object
*/
static public function createConfigObject()
{
// for backward compatibility
Zend_Registry::set('config', new Piwik_Config_Compat());
// instantiate the singleton
$config = Piwik_Config::getInstance();
$config->init();
}
/*
* Global access object
*/
......
......@@ -343,11 +343,7 @@ class Piwik_Tracker
} catch (Exception $e) {
Piwik::createAccessObject();
}
try {
$config = Piwik_Config::getInstance();
} catch (Exception $e) {
Piwik::createConfigObject();
}
$config = Piwik_Config::getInstance();
try {
$db = Zend_Registry::get('db');
} catch (Exception $e) {
......
......@@ -4,7 +4,6 @@ class Test_Piwik_DataTable_Array extends PHPUnit_Framework_TestCase
public function setUp()
{
parent::setUp();
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
Piwik_DataTable_Manager::getInstance()->deleteAll();
}
......
......@@ -580,7 +580,6 @@ class IPTest extends PHPUnit_Framework_TestCase
*/
public function testGetIpFromHeader($description, $test)
{
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
$_SERVER['REMOTE_ADDR'] = $test[0];
......
......@@ -23,7 +23,6 @@ class DatabaseTestCase extends PHPUnit_Framework_TestCase
{
parent::setUp();
try {
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
$dbConfig = Piwik_Config::getInstance()->database;
......
......@@ -27,7 +27,6 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
*/
public static function createTestConfig()
{
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
}
......
......@@ -24,7 +24,6 @@ class Piwik_FrontController_Test extends Piwik_FrontController
protected function createConfigObject()
{
// Config files forced to use the test database
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
}
......
......@@ -22,7 +22,6 @@ require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
// Config files forced to use the test database
// Note that this also provides security for Piwik installs containing tests files:
// this proxy will not record any data in the production database.
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
Piwik_Config::getInstance()->PluginsInstalled['PluginsInstalled'] = array();
try {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter