From 221acd4ee48de6a25b3f453828fa6d6c6dd1b43f Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sun, 23 Aug 2015 15:31:36 -0700 Subject: [PATCH] BagOStuff: Don't try to access a protected variable in a closure Follows up 78f1fee5593781b. Change-Id: Id356509cc55a5953351dfd98896cf01055739ee0 --- includes/libs/objectcache/BagOStuff.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 ); -- 2.20.1