diff --git a/core/Db.php b/core/Db.php index 5434a9777bf08a722c823063e47c8549cc0dc395..a418e490ea05db00cbb9b54c761f6f90d963fc9c 100644 --- a/core/Db.php +++ b/core/Db.php @@ -341,6 +341,15 @@ class Db return self::query("DROP TABLE " . implode(',', $tables)); } + /** + * Drops all tables + */ + static public function dropAllTables() + { + $tablesAlreadyInstalled = DbHelper::getTablesInstalled(); + self::dropTables($tablesAlreadyInstalled); + } + /** * Get columns information from table * diff --git a/core/Db/Schema.php b/core/Db/Schema.php index 065a9c973dca63f6df3322883667341101206c09..b7de26b6e3d0168c68669674ca71718543438a40 100644 --- a/core/Db/Schema.php +++ b/core/Db/Schema.php @@ -211,16 +211,6 @@ class Schema extends Singleton $this->getSchema()->truncateAllTables(); } - /** - * Drop specific tables - * - * @param array $doNotDelete - */ - public function dropTables($doNotDelete = array()) - { - $this->getSchema()->dropTables($doNotDelete); - } - /** * Names of all the prefixed tables in piwik * Doesn't use the DB diff --git a/core/Db/Schema/Mysql.php b/core/Db/Schema/Mysql.php index 34c3764f2fdc6b11f4ecb9d5e88c8bd449a9f7aa..bb5cc214bbc3c3f5f96b1b25c43852a1a60d3536 100644 --- a/core/Db/Schema/Mysql.php +++ b/core/Db/Schema/Mysql.php @@ -514,29 +514,6 @@ class Mysql implements SchemaInterface } } - /** - * Drop specific tables - * - * @param array $doNotDelete Names of tables to not delete - */ - public function dropTables($doNotDelete = array()) - { - $tablesAlreadyInstalled = $this->getTablesInstalled(); - $db = Db::get(); - - $doNotDeletePattern = '/(' . implode('|', $doNotDelete) . ')/'; - - foreach ($tablesAlreadyInstalled as $tableName) { - if (count($doNotDelete) == 0 - || (!in_array($tableName, $doNotDelete) - && !preg_match($doNotDeletePattern, $tableName) - ) - ) { - $db->query("DROP TABLE `$tableName`"); - } - } - } - private function getTablePrefix() { $dbInfos = Db::getDatabaseConfig(); diff --git a/core/Db/SchemaInterface.php b/core/Db/SchemaInterface.php index 18888fae7ba8f2cc88d4e9c1269de3d9b5d5e46c..71bc1b7d415f103aab2c289ecfd543f4ee3c5311 100644 --- a/core/Db/SchemaInterface.php +++ b/core/Db/SchemaInterface.php @@ -71,13 +71,6 @@ interface SchemaInterface */ public function truncateAllTables(); - /** - * Drop specific tables - * - * @param array $doNotDelete Names of tables to not delete - */ - public function dropTables($doNotDelete = array()); - /** * Names of all the prefixed tables in piwik * Doesn't use the DB diff --git a/core/DbHelper.php b/core/DbHelper.php index 7bb57e13f91e773ff5f17083a847db91e681b1d7..761bce2684db9663b8323c90e537cb6d4e9346ad 100644 --- a/core/DbHelper.php +++ b/core/DbHelper.php @@ -49,16 +49,6 @@ class DbHelper Schema::getInstance()->createTable($nameWithoutPrefix, $createDefinition); } - /** - * Drop specific tables - * - * @param array $doNotDelete Names of tables to not delete - */ - public static function dropTables($doNotDelete = array()) - { - Schema::getInstance()->dropTables($doNotDelete); - } - /** * Returns true if Piwik is installed * diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php index 8fe9c75118709e20716ed83232d37f87159983c1..b988fa04b8e64a4ea9966d32a71356598588f400 100644 --- a/plugins/Installation/Controller.php +++ b/plugins/Installation/Controller.php @@ -274,7 +274,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $this->skipThisStep(__FUNCTION__); if (Common::getRequestVar('deleteTables', 0, 'int') == 1) { - DbHelper::dropTables(); + Db::dropAllTables(); $view->existingTablesDeleted = true; // when the user decides to drop the tables then we dont skip the next steps anymore diff --git a/plugins/TreemapVisualization b/plugins/TreemapVisualization index 2cb15300a88f7ff2a1fc27ef633a1a1f4d5fef09..19978cb7cd926ec0fba111ce257b8f0450f34ce8 160000 --- a/plugins/TreemapVisualization +++ b/plugins/TreemapVisualization @@ -1 +1 @@ -Subproject commit 2cb15300a88f7ff2a1fc27ef633a1a1f4d5fef09 +Subproject commit 19978cb7cd926ec0fba111ce257b8f0450f34ce8 diff --git a/tests/PHPUnit/Fixtures/SqlDump.php b/tests/PHPUnit/Fixtures/SqlDump.php index e66dadc810396d77f8e80d01e18e1e361ec8ecea..716d36fd99164dc9a3e40a2175aaa6c965f97f75 100644 --- a/tests/PHPUnit/Fixtures/SqlDump.php +++ b/tests/PHPUnit/Fixtures/SqlDump.php @@ -26,7 +26,7 @@ class Piwik_Test_Fixture_SqlDump extends Fixture public function setUp() { // drop all tables - DbHelper::dropTables(); + Db::dropAllTables(); // download data dump if url supplied if (is_file($this->dumpUrl)) {