diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-07-23 11:52:15 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-07-23 11:52:15 +0400 |
commit | 5104d94f3b2250f766b9c520e2da8da9b4cab2e9 (patch) | |
tree | 5f30daf7bc14373fb1bbd0504ce11a771dafc02f /plugins/PrivacyManager/ReportsPurger.php | |
parent | ae4b1f4e38077b174e4df5b7d4513d63fe026a24 (diff) |
Refs #4059 Work in progress: Conversion to use Namespaces of dozen more classes
Removed many Piwik_ functions, in Piwik 2 it is best practise to use the methods calls instead
Todo: finish converting core/ classes + convert plugins/ classes to use \Piwik\Plugin namespace + fix build + Merge master
Diffstat (limited to 'plugins/PrivacyManager/ReportsPurger.php')
-rwxr-xr-x | plugins/PrivacyManager/ReportsPurger.php | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/plugins/PrivacyManager/ReportsPurger.php b/plugins/PrivacyManager/ReportsPurger.php index a8ed8c3bfa..af527b6142 100755 --- a/plugins/PrivacyManager/ReportsPurger.php +++ b/plugins/PrivacyManager/ReportsPurger.php @@ -11,6 +11,7 @@ use Piwik\DataAccess\ArchiveTableCreator; use Piwik\Piwik; use Piwik\Date; +use Piwik\Db; /** * Purges archived reports and metrics that are considered old. @@ -107,18 +108,18 @@ class Piwik_PrivacyManager_ReportsPurger if (!empty($oldBlobTables)) { // if no reports should be kept, drop tables, otherwise drop individual reports if (empty($this->reportPeriodsToKeep) && !$this->keepSegmentReports) { - Piwik_DropTables($oldBlobTables); + Db::dropTables($oldBlobTables); } else { foreach ($oldBlobTables as $table) { $where = $this->getBlobTableWhereExpr($oldNumericTables, $table); if (!empty($where)) { $where = "WHERE $where"; } - Piwik_DeleteAllRows($table, $where, $this->maxRowsToDeletePerQuery); + Db::deleteAllRows($table, $where, $this->maxRowsToDeletePerQuery); } if ($optimize) { - Piwik_OptimizeTables($oldBlobTables); + Db::optimizeTables($oldBlobTables); } } } @@ -129,15 +130,15 @@ class Piwik_PrivacyManager_ReportsPurger if ($this->keepBasicMetrics == 1 && !empty($this->metricsToKeep)) { $where = "WHERE name NOT IN ('" . implode("','", $this->metricsToKeep) . "') AND name NOT LIKE 'done%'"; foreach ($oldNumericTables as $table) { - Piwik_DeleteAllRows($table, $where, $this->maxRowsToDeletePerQuery); + Db::deleteAllRows($table, $where, $this->maxRowsToDeletePerQuery); } if ($optimize) { - Piwik_OptimizeTables($oldNumericTables); + Db::optimizeTables($oldNumericTables); } } else // drop numeric tables { - Piwik_DropTables($oldNumericTables); + Db::dropTables($oldNumericTables); } } } @@ -249,7 +250,7 @@ class Piwik_PrivacyManager_ReportsPurger private function getNumericTableDeleteCount($table) { - $maxIdArchive = Piwik_FetchOne("SELECT MAX(idarchive) FROM $table"); + $maxIdArchive = Db::fetchOne("SELECT MAX(idarchive) FROM $table"); $sql = "SELECT COUNT(*) FROM $table @@ -258,13 +259,13 @@ class Piwik_PrivacyManager_ReportsPurger AND idarchive >= ? AND idarchive < ?"; - $segments = Piwik_SegmentedFetchOne($sql, 0, $maxIdArchive, self::$selectSegmentSize); + $segments = Db::segmentedFetchOne($sql, 0, $maxIdArchive, self::$selectSegmentSize); return array_sum($segments); } private function getBlobTableDeleteCount($oldNumericTables, $table) { - $maxIdArchive = Piwik_FetchOne("SELECT MAX(idarchive) FROM $table"); + $maxIdArchive = Db::fetchOne("SELECT MAX(idarchive) FROM $table"); $sql = "SELECT COUNT(*) FROM $table @@ -272,7 +273,7 @@ class Piwik_PrivacyManager_ReportsPurger AND idarchive >= ? AND idarchive < ?"; - $segments = Piwik_SegmentedFetchOne($sql, 0, $maxIdArchive, self::$selectSegmentSize); + $segments = Db::segmentedFetchOne($sql, 0, $maxIdArchive, self::$selectSegmentSize); return array_sum($segments); } @@ -312,7 +313,7 @@ class Piwik_PrivacyManager_ReportsPurger foreach ($numericTables as $table) { $tableDate = ArchiveTableCreator::getDateFromTableName($table); - $maxIdArchive = Piwik_FetchOne("SELECT MAX(idarchive) FROM $table"); + $maxIdArchive = Db::fetchOne("SELECT MAX(idarchive) FROM $table"); $sql = "SELECT idarchive FROM $table @@ -322,7 +323,7 @@ class Piwik_PrivacyManager_ReportsPurger AND idarchive < ?"; $this->segmentArchiveIds[$tableDate] = array(); - foreach (Piwik_SegmentedFetchAll($sql, 0, $maxIdArchive, self::$selectSegmentSize) as $row) { + foreach (Db::segmentedFetchAll($sql, 0, $maxIdArchive, self::$selectSegmentSize) as $row) { $this->segmentArchiveIds[$tableDate][] = $row['idarchive']; } } |