public function test_purgeArchivesWithPeriodRange_PurgesAllRangeArchives() { $deletedRowCount = $this->archivePurger->purgeArchivesWithPeriodRange($this->february); self::$fixture->assertCustomRangesPurged($this->february); self::$fixture->assertCustomRangesNotPurged($this->january); $this->assertEquals(3 * RawArchiveDataWithTempAndInvalidated::ROWS_PER_ARCHIVE, $deletedRowCount); }
/** * @return bool `true` if the purge was executed, `false` if it was skipped. * @throws \Exception */ public function purgeOutdatedArchives() { if ($this->willPurgingCausePotentialProblemInUI()) { $this->logger->info("Purging temporary archives: skipped (browser triggered archiving not enabled & not running after core:archive)"); return false; } $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled(); $this->logger->info("Purging archives in {tableCount} archive tables.", array('tableCount' => count($archiveTables))); // keep track of dates we purge for, since getTablesArchivesInstalled() will return numeric & blob // tables (so dates will appear two times, and we should only purge once per date) $datesPurged = array(); foreach ($archiveTables as $table) { $date = ArchiveTableCreator::getDateFromTableName($table); list($year, $month) = explode('_', $date); // Somehow we may have archive tables created with older dates, prevent exception from being thrown if ($year > 1990) { if (empty($datesPurged[$date])) { $dateObj = Date::factory("{$year}-{$month}-15"); $this->archivePurger->purgeOutdatedArchives($dateObj); $this->archivePurger->purgeArchivesWithPeriodRange($dateObj); $datesPurged[$date] = true; } else { $this->logger->debug("Date {date} already purged.", array('date' => $date)); } } else { $this->logger->info("Skipping purging of archive tables *_{year}_{month}, year <= 1990.", array('year' => $year, 'month' => $month)); } } return true; }