Ejemplo n.º 1
0
	protected function checkTableExists()
	{
		if(is_null(self::$tablesAlreadyInstalled))
		{
			self::$tablesAlreadyInstalled = Piwik::getTablesInstalled($forceReload = false);
		}
		
		if(!in_array($this->generatedTableName, self::$tablesAlreadyInstalled))
		{
			$db = Zend_Registry::get('db');
			$sql = Piwik::getTableCreateSql($this->tableName);
			
			$config = Zend_Registry::get('config');
			$prefixTables = $config->database->tables_prefix;
			$sql = str_replace( $prefixTables . $this->tableName, $this->generatedTableName, $sql);
			try {
				$db->query( $sql );
			} catch(Exception $e) {
				// mysql error 1050: table already exists
				if(! $db->isErrNo($e, '1050'))
				{
					// failed for some other reason
					throw $e;
				}
			}
			
			self::$tablesAlreadyInstalled[] = $this->generatedTableName;
		}
	}
 function tearDown()
 {
     parent::tearDown();
     $_GET = array();
     $_POST = array();
     $_REQUEST = array();
     Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
 }
Ejemplo n.º 3
0
 public function tearDown()
 {
     parent::tearDown();
     Piwik_DataTable_Manager::getInstance()->deleteAll();
     Piwik_Option::getInstance()->clearCache();
     Piwik_Common::deleteTrackerCache();
     Piwik_Site::clearCache();
     Piwik::truncateAllTables();
     Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
 }
Ejemplo n.º 4
0
 protected function checkTableExists()
 {
     if (is_null(self::$tablesAlreadyInstalled)) {
         self::$tablesAlreadyInstalled = Piwik::getTablesInstalled($forceReload = false);
     }
     if (!in_array($this->generatedTableName, self::$tablesAlreadyInstalled)) {
         $db = Zend_Registry::get('db');
         $sql = Piwik::getTableCreateSql($this->tableName);
         $config = Zend_Registry::get('config');
         $prefixTables = $config->database->tables_prefix;
         $sql = str_replace($prefixTables . $this->tableName, $this->generatedTableName, $sql);
         $db->query($sql);
         self::$tablesAlreadyInstalled[] = $this->generatedTableName;
     }
 }
Ejemplo n.º 5
0
 public function tearDown()
 {
     parent::tearDown();
     Piwik::$lockPrivilegeGranted = null;
     // remove archive tables (integration test teardown will only truncate)
     $archiveTables = $this->getArchiveTableNames();
     $archiveTables = array_merge($archiveTables['numeric'], $archiveTables['blob']);
     foreach ($archiveTables as $table) {
         Piwik_Query("DROP TABLE IF EXISTS " . Piwik_Common::prefixTable($table));
     }
     // refresh table name caches so next test will pass
     Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
     Piwik::getTablesInstalled(true);
     // drop temporary tables
     $tempTableName = Piwik_PrivacyManager_LogDataPurger::TEMP_TABLE_NAME;
     Piwik_Query("DROP TABLE IF EXISTS " . Piwik_Common::prefixTable($tempTableName));
 }
Ejemplo n.º 6
0
 /**
  * Resets all caches and drops the database
  */
 public function tearDown()
 {
     parent::tearDown();
     try {
         $plugins = Piwik_PluginsManager::getInstance()->getLoadedPlugins();
         foreach ($plugins as $plugin) {
             $plugin->uninstall();
         }
         Piwik_PluginsManager::getInstance()->unloadPlugins();
     } catch (Exception $e) {
     }
     Piwik::dropDatabase();
     Piwik_DataTable_Manager::getInstance()->deleteAll();
     Piwik_Option::getInstance()->clearCache();
     Piwik_Site::clearCache();
     Piwik_Common::deleteTrackerCache();
     Piwik_Config::getInstance()->clear();
     Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
     Zend_Registry::_unsetInstance();
 }
Ejemplo n.º 7
0
 public static function tearDownAfterClass()
 {
     try {
         $plugins = Piwik_PluginsManager::getInstance()->getLoadedPlugins();
         foreach ($plugins as $plugin) {
             $plugin->uninstall();
         }
         Piwik_PluginsManager::getInstance()->unloadPlugins();
     } catch (Exception $e) {
     }
     Piwik::dropDatabase();
     Piwik_DataTable_Manager::getInstance()->deleteAll();
     Piwik_Option::getInstance()->clearCache();
     Piwik_Site::clearCache();
     Piwik_Common::deleteTrackerCache();
     Piwik_Config::getInstance()->clear();
     Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
     Zend_Registry::_unsetInstance();
     $_GET = $_REQUEST = array();
     Piwik_Translate::getInstance()->unloadEnglishTranslation();
     // re-enable tag cloud shuffling
     Piwik_Visualization_Cloud::$debugDisableShuffle = true;
 }
Ejemplo n.º 8
0
 public function setUp()
 {
     parent::setUp();
     Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
 }
Ejemplo n.º 9
0
 /**
  * Drops all archive tables.
  */
 public static function deleteArchiveTables()
 {
     foreach (Piwik::getTablesArchivesInstalled() as $table) {
         Piwik_Query("DROP TABLE IF EXISTS {$table}");
     }
     Piwik_TablePartitioning::$tablesAlreadyInstalled = Piwik::getTablesInstalled($forceReload = true);
 }
Ejemplo n.º 10
0
 public function tearDown()
 {
     parent::tearDown();
     Piwik_DataTable_Manager::getInstance()->deleteAll();
     Piwik_Option::getInstance()->clearCache();
     Piwik_Site::clearCache();
     Piwik_Common::deleteTrackerCache();
     Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
     $tempTableName = Piwik_Common::prefixTable(Piwik_PrivacyManager_LogDataPurger::TEMP_TABLE_NAME);
     Piwik_Query("DROP TABLE IF EXISTS " . $tempTableName);
 }