Remove support for object specific lifetimes in VisitTracker
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 26 Apr 2022 13:21:10 +0000 (15:21 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 26 Apr 2022 13:21:10 +0000 (15:21 +0200)
wcfsetup/install/files/lib/system/cronjob/DailyCleanUpCronjob.class.php
wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php

index ba0d4e99bc60f10cfcbf3612651f7944c7b5c000..7aaa4ca737fb6ffe266cc93eaaa39750be8aa435 100644 (file)
@@ -82,17 +82,16 @@ class DailyCleanUpCronjob extends AbstractCronjob
         $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.visitTracker.objectType');
         foreach ($objectTypes as $objectType) {
             $visitLifetime = 120 * 86400;
-            \assert($visitLifetime > VisitTracker::DEFAULT_LIFETIME);
-            $lifetime = \max($objectType->lifetime ?: 0, $visitLifetime);
+            \assert($visitLifetime > VisitTracker::LIFETIME);
 
             // delete data
             $statement1->execute([
                 $objectType->objectTypeID,
-                TIME_NOW - $lifetime,
+                TIME_NOW - $visitLifetime,
             ]);
             $statement2->execute([
                 $objectType->objectTypeID,
-                TIME_NOW - $lifetime,
+                TIME_NOW - $visitLifetime,
             ]);
         }
         WCF::getDB()->commitTransaction();
index 3fd3cea547769c7acda0437ac673a3915e29fdd6..0ca4f922742ce1612ec056a0d6deafcd442d3e25 100644 (file)
@@ -19,10 +19,15 @@ use wcf\system\WCF;
 class VisitTracker extends SingletonFactory
 {
     /**
-     * default tracking lifetime
-     * @var int
+     * @deprecated 5.5 Use VisitTracker::LIFETIME instead.
      */
-    const DEFAULT_LIFETIME = 31 * 86400;
+    const DEFAULT_LIFETIME = self::LIFETIME;
+
+    /**
+     * Objects older than this are considered visited.
+     * @since 5.5
+     */
+    public const LIFETIME = 31 * 86400;
 
     /**
      * list of available object types
@@ -103,8 +108,7 @@ class VisitTracker extends SingletonFactory
             }
         }
 
-        $lifetime = ($this->availableObjectTypes[$objectType]->lifetime) ?: self::DEFAULT_LIFETIME;
-        $minimum = TIME_NOW - $lifetime;
+        $minimum = TIME_NOW - self::LIFETIME;
 
         if (WCF::getUser()->userID) {
             // Mark everything before the registration date as read.