From: Kunal Mehta Date: Sun, 23 Aug 2015 22:31:36 +0000 (-0700) Subject: BagOStuff: Don't try to access a protected variable in a closure X-Git-Tag: 1.31.0-rc.0~10301 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_user_edit%27%2C%20iduser=user.userid%29%20%7D%7D?a=commitdiff_plain;h=221acd4ee48de6a25b3f453828fa6d6c6dd1b43f;p=lhc%2Fweb%2Fwiklou.git BagOStuff: Don't try to access a protected variable in a closure Follows up 78f1fee5593781b. Change-Id: Id356509cc55a5953351dfd98896cf01055739ee0 --- diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index 83e015331a..5004a8a6b1 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -289,13 +289,15 @@ abstract class BagOStuff implements LoggerAwareInterface { } $lSince = microtime( true ); // lock timestamp + // PHP 5.3: Can't use $this in a closure $that = $this; + $logger = $this->logger; - return new ScopedCallback( function() use ( $that, $key, $lSince, $expiry ) { + return new ScopedCallback( function() use ( $that, $logger, $key, $lSince, $expiry ) { $latency = .050; // latency skew (err towards keeping lock present) $age = ( microtime( true ) - $lSince + $latency ); if ( ( $age + $latency ) >= $expiry ) { - $that->logger->warning( "Lock for $key held too long ($age sec)." ); + $logger->warning( "Lock for $key held too long ($age sec)." ); return; // expired; it's not "safe" to delete the key } $that->unlock( $key );