From: Tim Düsterhus Date: Tue, 26 Apr 2022 12:44:27 +0000 (+0200) Subject: Fix cleaning of tracked visits in DailyCleanUpCronjob X-Git-Tag: 5.5.0_Alpha_4~2^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e139fd483709c1eb3fd5d23797e504b948c06c7d;p=GitHub%2FWoltLab%2FWCF.git Fix cleaning of tracked visits in DailyCleanUpCronjob This part of the cronjob never was functional, because stored visitTime was compared to the lifetime which could only ever match near the start of the unix epoch. Fix this by correctly subtracting the lifetime from the current timestamp. I've opted to use 120 days as the cleanup lifetime, as this allows one to adjust the DEFAULT_LIFETIME gracefully. --- diff --git a/wcfsetup/install/files/lib/system/cronjob/DailyCleanUpCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/DailyCleanUpCronjob.class.php index d6bf033e6c..ba0d4e99bc 100644 --- a/wcfsetup/install/files/lib/system/cronjob/DailyCleanUpCronjob.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/DailyCleanUpCronjob.class.php @@ -81,17 +81,18 @@ class DailyCleanUpCronjob extends AbstractCronjob WCF::getDB()->beginTransaction(); $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.visitTracker.objectType'); foreach ($objectTypes as $objectType) { - // get lifetime - $lifetime = ($objectType->lifetime ?: VisitTracker::DEFAULT_LIFETIME); + $visitLifetime = 120 * 86400; + \assert($visitLifetime > VisitTracker::DEFAULT_LIFETIME); + $lifetime = \max($objectType->lifetime ?: 0, $visitLifetime); // delete data $statement1->execute([ $objectType->objectTypeID, - $lifetime, + TIME_NOW - $lifetime, ]); $statement2->execute([ $objectType->objectTypeID, - $lifetime, + TIME_NOW - $lifetime, ]); } WCF::getDB()->commitTransaction();