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.
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();