diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2020-09-11 04:19:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-11 04:19:41 +0300 |
commit | 6b70e8cc7a12e596bfa08e35db52531ce989c2f2 (patch) | |
tree | 151cda62467fb0c5266adb6e901c3bd50499fb2b /plugins | |
parent | d01085cec58a437e30b0dd4b149c52fc3e19abaa (diff) |
Add methods to remove invalidations. (#16400)
* Add methods to remove invalidations.
* Add check if site exists to beginning of queue consumers loop to find archive data
* Delete invalidations w/ no site in task and for site when deleting.
* fix test
* fix test
* another test fix
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/CoreAdminHome/Tasks.php | 8 | ||||
-rw-r--r-- | plugins/CoreAdminHome/tests/Integration/TasksTest.php | 1 | ||||
-rw-r--r-- | plugins/SitesManager/API.php | 4 |
3 files changed, 13 insertions, 0 deletions
diff --git a/plugins/CoreAdminHome/Tasks.php b/plugins/CoreAdminHome/Tasks.php index 21008b78a3..9cccf23aba 100644 --- a/plugins/CoreAdminHome/Tasks.php +++ b/plugins/CoreAdminHome/Tasks.php @@ -18,6 +18,7 @@ use Piwik\Config; use Piwik\Container\StaticContainer; use Piwik\CronArchive; use Piwik\DataAccess\ArchiveTableCreator; +use Piwik\DataAccess\Model as CoreModel; use Piwik\Date; use Piwik\Db; use Piwik\Http; @@ -75,6 +76,7 @@ class Tasks extends \Piwik\Plugin\Tasks // general data purge on invalidated archive records, executed daily $this->daily('purgeInvalidatedArchives', null, self::LOW_PRIORITY); + $this->daily('purgeInvalidationsForDeletedSites', null, self::LOW_PRIORITY); $this->weekly('purgeOrphanedArchives', null, self::NORMAL_PRIORITY); @@ -92,6 +94,12 @@ class Tasks extends \Piwik\Plugin\Tasks $this->scheduleTrackingCodeReminderChecks(); } + public function purgeInvalidationsForDeletedSites() + { + $coreModel = new CoreModel(); + $coreModel->deleteInvalidationsForDeletedSites(); + } + public function deleteOldFingerprintSalts() { StaticContainer::get(FingerprintSalt::class)->deleteOldSalts(); diff --git a/plugins/CoreAdminHome/tests/Integration/TasksTest.php b/plugins/CoreAdminHome/tests/Integration/TasksTest.php index e98791a131..9edcbc5fcc 100644 --- a/plugins/CoreAdminHome/tests/Integration/TasksTest.php +++ b/plugins/CoreAdminHome/tests/Integration/TasksTest.php @@ -136,6 +136,7 @@ class TasksTest extends IntegrationTestCase 'deleteOldFingerprintSalts.', 'purgeOutdatedArchives.', 'purgeInvalidatedArchives.', + 'purgeInvalidationsForDeletedSites.', 'purgeOrphanedArchives.', 'optimizeArchiveTable.', 'cleanupTrackingFailures.', diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php index ef6f85c8ca..d52003a71f 100644 --- a/plugins/SitesManager/API.php +++ b/plugins/SitesManager/API.php @@ -34,6 +34,7 @@ use Piwik\Tracker\TrackerCodeGenerator; use Piwik\Measurable\Type; use Piwik\Url; use Piwik\UrlHelper; +use Piwik\DataAccess\Model as CoreModel; /** * The SitesManager API gives you full control on Websites in Matomo (create, update and delete), and many methods to retrieve websites based on various attributes. @@ -782,6 +783,9 @@ class API extends \Piwik\Plugin\API $this->getModel()->deleteSite($idSite); + $coreModel = new CoreModel(); + $coreModel->deleteInvalidationsForSites([$idSite]); + /** * Triggered after a site has been deleted. * |