From: Kunal Mehta Date: Tue, 13 Sep 2016 04:23:09 +0000 (-0700) Subject: MapCacheLRU: Support null values in getWithSetCallback() X-Git-Tag: 1.31.0-rc.0~5624^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=a41f187511060015bd06ae3cb5b30e95e9e36180 MapCacheLRU: Support null values in getWithSetCallback() The rest of this class supports having a key with a null value by using array_key_exists() instead of isset(). So Use $this->has() in getWithSetCallback() so a null value is still identified as set. Change-Id: Ida74a6f7e284e98f9a7d76d97312ebe2ee343f10 --- diff --git a/includes/libs/MapCacheLRU.php b/includes/libs/MapCacheLRU.php index 90c9a754a4..2f5a454f5d 100644 --- a/includes/libs/MapCacheLRU.php +++ b/includes/libs/MapCacheLRU.php @@ -115,8 +115,9 @@ class MapCacheLRU { * @return mixed The cached value if found or the result of $callback otherwise */ public function getWithSetCallback( $key, callable $callback ) { - $value = $this->get( $key ); - if ( $value === null ) { + if ( $this->has( $key ) ) { + $value = $this->get( $key ); + } else { $value = call_user_func( $callback ); if ( $value !== false ) { $this->set( $key, $value );