diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-03-30 02:53:44 +0400 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-03-30 02:53:44 +0400 |
commit | 7b3d0025c861bff8d9230faafae5d6ffff8f912c (patch) | |
tree | eec382bef07c78ffe73b3a3e43d54ac7ab7dfbce /core | |
parent | 93bc0691d9ff6b02d782f0c18212c69ca49c38fb (diff) |
- fixes #582 API UsersManager.* accepting $userLogin should work well when super user login is passed
+ adding tests
- tests are much faster now: only creating/droping DB and tables once per class rather than once per method
- fixing broken test (infinite recursion in datatable calls destruct +100 times)
Diffstat (limited to 'core')
-rw-r--r-- | core/Common.php | 2 | ||||
-rw-r--r-- | core/DataTable.php | 8 | ||||
-rw-r--r-- | core/Piwik.php | 13 |
3 files changed, 18 insertions, 5 deletions
diff --git a/core/Common.php b/core/Common.php index 25c156efbe..2cc6ade424 100644 --- a/core/Common.php +++ b/core/Common.php @@ -47,7 +47,7 @@ class Piwik_Common static public function prefixTable($table) { $prefixTable = false; - if(class_exists('Piwik_Tracker_Config')) + if(defined('PIWIK_TRACKER_MODE') && PIWIK_TRACKER_MODE) { $prefixTable = Piwik_Tracker_Config::getInstance()->database['tables_prefix']; } diff --git a/core/DataTable.php b/core/DataTable.php index 82dc72b74a..e1d956e1e4 100644 --- a/core/DataTable.php +++ b/core/DataTable.php @@ -220,7 +220,7 @@ class Piwik_DataTable * * @var int */ - const MAXIMUM_DEPTH_LEVEL_ALLOWED = 20; + const MAXIMUM_DEPTH_LEVEL_ALLOWED = 15; /** * Builds the DataTable, registers itself to the manager @@ -236,14 +236,18 @@ class Piwik_DataTable */ public function __destruct() { + static $depth = 0; // destruct can be called several times - if(isset($this->rows)) + if($depth < self::MAXIMUM_DEPTH_LEVEL_ALLOWED + && isset($this->rows)) { + $depth++; foreach($this->getRows() as $row) { destroy($row); } unset($this->rows); Piwik_DataTable_Manager::getInstance()->setTableDeleted($this->getId()); + $depth--; } } diff --git a/core/Piwik.php b/core/Piwik.php index bc49c0051e..c01610feb0 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -1155,9 +1155,9 @@ class Piwik Zend_Registry::get('db')->query("CREATE DATABASE IF NOT EXISTS ".$dbName); } - static public function dropTestDatabase() + static public function dropDatabase() { - $dbName = Zend_Registry::get('config')->database_tests->dbname; + $dbName = Zend_Registry::get('config')->database->dbname; Zend_Registry::get('db')->query("DROP DATABASE IF EXISTS " . $dbName); } @@ -1332,6 +1332,15 @@ class Piwik } } + static public function truncateAllTables() + { + $tablesAlreadyInstalled = self::getTablesInstalled($forceReload = true); + foreach($tablesAlreadyInstalled as $table) + { + Zend_Registry::get('db')->query("TRUNCATE `$table`"); + } + } + static public function install() { Piwik_Common::mkdir(Zend_Registry::get('config')->smarty->compile_dir); |