From e48fec5a8ab5916735849d420f2dfeec7eb0fced Mon Sep 17 00:00:00 2001 From: "Ori.livneh" Date: Fri, 31 Jul 2015 23:13:35 +0000 Subject: [PATCH] Revert I4afaecd8: Avoiding writing sessions for no reason I4afaecd8 reduced the frequency at which the TTL of sessions keys is reset, on the assumption that we were doing it a whole lot more often than necessary. We can now assume that this assumption was false, because an uncommitted revert of this change which I pushed to production earlier caused the rate of session loss errors in the logs to plummet. Bug: T102199 Change-Id: Ie67f4ca000afcf3d4f44155c13f91cd4c286866d --- .../objectcache/ObjectCacheSessionHandler.php | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/includes/objectcache/ObjectCacheSessionHandler.php b/includes/objectcache/ObjectCacheSessionHandler.php index ae3850f85c..1430dd8c3d 100644 --- a/includes/objectcache/ObjectCacheSessionHandler.php +++ b/includes/objectcache/ObjectCacheSessionHandler.php @@ -28,8 +28,6 @@ * @ingroup Cache */ class ObjectCacheSessionHandler { - /** @var array Map of (session ID => SHA-1 of the data) */ - protected static $hashCache = array(); const TTL_REFRESH_WINDOW = 600; // refresh if expiring in 10 minutes @@ -58,7 +56,6 @@ class ObjectCacheSessionHandler { */ protected static function getCache() { global $wgSessionCacheType; - return ObjectCache::getInstance( $wgSessionCacheType ); } @@ -72,14 +69,6 @@ class ObjectCacheSessionHandler { return wfMemcKey( 'session', $id ); } - /** - * @param mixed $data - * @return string - */ - protected static function getHash( $data ) { - return sha1( serialize( $data ) ); - } - /** * Callback when opening a session. * @@ -109,10 +98,10 @@ class ObjectCacheSessionHandler { */ static function read( $id ) { $data = self::getCache()->get( self::getKey( $id ) ); - - self::$hashCache = array( $id => self::getHash( $data ) ); - - return ( $data === false ) ? '' : $data; + if ( $data === false ) { + return ''; + } + return $data; } /** @@ -124,14 +113,7 @@ class ObjectCacheSessionHandler { */ static function write( $id, $data ) { global $wgObjectCacheSessionExpiry; - - // Only issue a write if anything changed (PHP 5.6 already does this) - if ( !isset( self::$hashCache[$id] ) - || self::getHash( $data ) !== self::$hashCache[$id] - ) { - self::getCache()->set( self::getKey( $id ), $data, $wgObjectCacheSessionExpiry ); - } - + self::getCache()->set( self::getKey( $id ), $data, $wgObjectCacheSessionExpiry ); return true; } -- 2.20.1