diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2020-05-22 01:05:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-22 01:05:12 +0300 |
commit | 3aa66a20ff73f0e3f559c074846fef6763ea0d2c (patch) | |
tree | 54f325b1fd03b5fbabbe8caa93a4d0e2b7d9c0a6 /plugins | |
parent | 723e92f382f2078d2495662f785ac9cf3e6fe29b (diff) |
Limit the fingerprint (#15886)
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/SitesManager.php | 12 |
3 files changed, 21 insertions, 0 deletions
diff --git a/plugins/CoreAdminHome/Tasks.php b/plugins/CoreAdminHome/Tasks.php index 97180241cc..24d06d1b17 100644 --- a/plugins/CoreAdminHome/Tasks.php +++ b/plugins/CoreAdminHome/Tasks.php @@ -32,6 +32,7 @@ use Piwik\Scheduler\Schedule\SpecificTime; use Piwik\Settings\Storage\Backend\MeasurableSettingsTable; use Piwik\Tracker\Failures; use Piwik\Site; +use Piwik\Tracker\FingerprintSalt; use Piwik\Tracker\Visit\ReferrerSpamFilter; use Psr\Log\LoggerInterface; use Piwik\SettingsPiwik; @@ -67,6 +68,8 @@ class Tasks extends \Piwik\Plugin\Tasks // sure all archives that need to be invalidated get invalidated $this->daily('invalidateOutdatedArchives', null, self::HIGH_PRIORITY); + $this->daily('deleteOldFingerprintSalts', null, self::HIGH_PRIORITY); + // general data purge on older archive tables, executed daily $this->daily('purgeOutdatedArchives', null, self::HIGH_PRIORITY); @@ -88,6 +91,11 @@ class Tasks extends \Piwik\Plugin\Tasks $this->scheduleTrackingCodeReminderChecks(); } + public function deleteOldFingerprintSalts() + { + StaticContainer::get(FingerprintSalt::class)->deleteOldSalts(); + } + public function invalidateOutdatedArchives() { if (!Rules::isBrowserTriggerEnabled()) { diff --git a/plugins/CoreAdminHome/tests/Integration/TasksTest.php b/plugins/CoreAdminHome/tests/Integration/TasksTest.php index 89c62252d5..b4e0c03d5a 100644 --- a/plugins/CoreAdminHome/tests/Integration/TasksTest.php +++ b/plugins/CoreAdminHome/tests/Integration/TasksTest.php @@ -133,6 +133,7 @@ class TasksTest extends IntegrationTestCase $expected = [ 'invalidateOutdatedArchives.', + 'deleteOldFingerprintSalts.', 'purgeOutdatedArchives.', 'purgeInvalidatedArchives.', 'purgeOrphanedArchives.', diff --git a/plugins/SitesManager/SitesManager.php b/plugins/SitesManager/SitesManager.php index 1320c0f6f2..2b8e767b26 100644 --- a/plugins/SitesManager/SitesManager.php +++ b/plugins/SitesManager/SitesManager.php @@ -13,12 +13,14 @@ use Piwik\API\Request; use Piwik\Common; use Piwik\Config; use Piwik\Container\StaticContainer; +use Piwik\Date; use Piwik\Exception\UnexpectedWebsiteFoundException; use Piwik\Option; use Piwik\Piwik; use Piwik\Plugins\CoreHome\SystemSummary; use Piwik\Settings\Storage\Backend\MeasurableSettingsTable; use Piwik\Tracker\Cache; +use Piwik\Tracker\FingerprintSalt; use Piwik\Tracker\Model as TrackerModel; use Piwik\Session\SessionNamespace; @@ -197,6 +199,16 @@ class SitesManager extends \Piwik\Plugin $array['timezone'] = $this->getTimezoneFromWebsite($website); $array['ts_created'] = $website['ts_created']; $array['type'] = $website['type']; + + // we make sure to have the fingerprint salts for the last 3 days incl tmrw in the cache so we don't need to + // query the DB directly for these days + $datesToGenerateSalt = array(Date::now()->addDay(1), Date::now(), Date::now()->subDay(1), Date::now()->subDay(2)); + + $fingerprintSaltKey = new FingerprintSalt(); + foreach ($datesToGenerateSalt as $date) { + $dateString = $fingerprintSaltKey->getDateString($date, $array['timezone']); + $array[FingerprintSalt::OPTION_PREFIX . $dateString] = $fingerprintSaltKey->getSalt($dateString, $idSite); + } } public function setTrackerCacheGeneral(&$cache) |