]> git.mxchange.org Git - friendica.git/commitdiff
Fix wrong session expire set for custom duration
authorHypolite Petovan <mrpetovan@gmail.com>
Wed, 7 Mar 2018 02:34:00 +0000 (21:34 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Wed, 7 Mar 2018 02:34:00 +0000 (21:34 -0500)
src/Core/Cache.php
src/Core/Cache/DatabaseCacheDriver.php
src/Core/Cache/MemcacheCacheDriver.php
src/Core/Cache/MemcachedCacheDriver.php

index a1b1ecb9c171c199d47b58443a885f71c9c04a87..3f2edd2e20cefedafe4109194cf628ca096ed425 100644 (file)
@@ -12,14 +12,14 @@ use Friendica\Core\Config;
  */
 class Cache extends \Friendica\BaseObject
 {
-       const MONTH        = 0;
-       const WEEK         = 1;
-       const DAY          = 2;
-       const HOUR         = 3;
-       const HALF_HOUR    = 4;
-       const QUARTER_HOUR = 5;
-       const FIVE_MINUTES = 6;
-       const MINUTE       = 7;
+       const MONTH        = 2592000;
+       const WEEK         = 604800;
+       const DAY          = 86400;
+       const HOUR         = 3600;
+       const HALF_HOUR    = 1800;
+       const QUARTER_HOUR = 900;
+       const FIVE_MINUTES = 300;
+       const MINUTE       = 60;
 
        /**
         * @var Cache\ICacheDriver
@@ -45,45 +45,6 @@ class Cache extends \Friendica\BaseObject
                }
        }
 
-       /**
-        * @brief Return the duration for a given cache level
-        *
-        * @param integer $level Cache level
-        *
-        * @return integer The cache duration in seconds
-        */
-       public static function duration($level)
-       {
-               switch ($level) {
-                       case self::MONTH:
-                               $seconds = 2592000;
-                               break;
-                       case self::WEEK:
-                               $seconds = 604800;
-                               break;
-                       case self::DAY:
-                               $seconds = 86400;
-                               break;
-                       case self::HOUR:
-                               $seconds = 3600;
-                               break;
-                       case self::HALF_HOUR:
-                               $seconds = 1800;
-                               break;
-                       case self::QUARTER_HOUR:
-                               $seconds = 900;
-                               break;
-                       case self::FIVE_MINUTES:
-                               $seconds = 300;
-                               break;
-                       case self::MINUTE:
-                       default:
-                               $seconds = 60;
-                               break;
-               }
-               return $seconds;
-       }
-
        /**
         * Returns the current cache driver
         *
index 9703208d7b48888024f4082b5417630a51332ca5..17ae310074b36a3c9cbd05370706d23e749f9935 100644 (file)
@@ -37,7 +37,7 @@ class DatabaseCacheDriver implements ICacheDriver
        {\r
                $fields = [\r
                        'v'       => serialize($value),\r
-                       'expires' => DateTimeFormat::utc('now + ' . Cache::duration($duration) . ' seconds'),\r
+                       'expires' => DateTimeFormat::utc('now + ' . $duration . ' seconds'),\r
                        'updated' => DateTimeFormat::utcNow()\r
                ];\r
 \r
index 03fc075f4b3fb8ad7f22d8f75a50a139f92d0d3c..563447ef1e438b0a193399bbdd3f348766599fac 100644 (file)
@@ -61,7 +61,7 @@ class MemcacheCacheDriver extends BaseObject implements ICacheDriver
                        self::getApp()->get_hostname() . ":" . $key,\r
                        serialize($value),\r
                        MEMCACHE_COMPRESSED,\r
-                       Cache::duration($duration)\r
+                       time() + $duration\r
                );\r
        }\r
 \r
index 8f1752cbed0ce5169b4b976abbb674e552f9fc73..1a8bdc95030bed39152c57128bc17dd650cb5bc0 100644 (file)
@@ -52,7 +52,7 @@ class MemcachedCacheDriver extends BaseObject implements ICacheDriver
                return $this->memcached->set(\r
                        self::getApp()->get_hostname() . ":" . $key,\r
                        $value,\r
-                       Cache::duration($duration)\r
+                       time() + $duration\r
                );\r
        }\r
 \r