/** Test no concurrency issues when deleting log data from log_action table. */
 public function test_purgeLogData_concurrency()
 {
     Piwik_AddAction("LogDataPurger.actionsToKeepInserted.olderThan", array($this, 'addReferenceToUnusedAction'));
     $this->addLogData();
     $purger = Piwik_PrivacyManager_LogDataPurger::make($this->settings, true);
     $this->unusedIdAction = Piwik_FetchOne("SELECT idaction FROM " . Piwik_Common::prefixTable('log_action') . " WHERE name = ?", array('whatever.com/_40'));
     $this->assertTrue($this->unusedIdAction);
     // purge data
     $purger->purgeData();
     // check that actions were purged
     $this->assertEqual(22, $this->getTableCount('log_action'));
     // January
     // check that the unused action still exists
     $count = Piwik_FetchOne("SELECT COUNT(*) FROM " . Piwik_Common::prefixTable('log_action') . " WHERE idaction = ?", array($this->unusedIdAction));
     $this->assertEqual(1, $count);
     $this->unusedIdAction = null;
     // so the hook won't get executed twice
 }
Beispiel #2
0
 /**
  * Returns an array describing what data would be purged if both log data & report
  * purging is invoked.
  * 
  * The returned array maps table names with the number of rows that will be deleted.
  * If the table name is mapped with -1, the table will be dropped.
  * 
  * @param array $settings The config options to use in the estimate. If null, the real
  *                        options are used.
  * @return array
  */
 public static function getPurgeEstimate($settings = null)
 {
     if (is_null($settings)) {
         $settings = self::getPurgeDataSettings();
     }
     $result = array();
     if ($settings['delete_logs_enable']) {
         $logDataPurger = Piwik_PrivacyManager_LogDataPurger::make($settings);
         $result = array_merge($result, $logDataPurger->getPurgeEstimate());
     }
     if ($settings['delete_reports_enable']) {
         $reportsPurger = Piwik_PrivacyManager_ReportsPurger::make($settings, self::getAllMetricsToKeep());
         $result = array_merge($result, $reportsPurger->getPurgeEstimate());
     }
     return $result;
 }