logDataAnonymizations = $logDataAnonymizations; $this->dataSubjects = $dataSubjects; $this->sitesManagerAPI = $sitesManagerAPI; } public function schedule() { $this->daily('deleteReportData', null, self::LOW_PRIORITY); $this->hourly('deleteLogData', null, self::LOW_PRIORITY); $this->hourly('anonymizePastData', null, self::LOW_PRIORITY); $this->weekly('deleteLogDataForDeletedSites', null, self::LOW_PRIORITY); } public function anonymizePastData() { $loop = 0; do { $loop++; // safety loop... $id = $this->logDataAnonymizations->getNextScheduledAnonymizationId(); if (!empty($id)) { $this->logDataAnonymizations->executeScheduledEntry($id); } } while (!empty($id) && $loop < 100); } public function deleteReportData() { $privacyManager = new PrivacyManager(); $privacyManager->deleteReportData(); } /** * To test execute the following command: * `./console core:run-scheduled-tasks "Piwik\Plugins\PrivacyManager\Tasks.deleteLogData"` */ public function deleteLogData() { $privacyManager = new PrivacyManager(); $privacyManager->deleteLogData(); } public function deleteLogDataForDeletedSites() { $allSiteIds = $this->sitesManagerAPI->getAllSitesId(); $this->dataSubjects->deleteDataSubjectsForDeletedSites($allSiteIds); } }