X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2Fobjectcache%2FWANObjectCache.php;h=658b225b44fed3b49cadbdd852ab362871e94741;hp=17f596d6b8804178414fb5acc70c0f59c1be5ca2;hb=631e8695b15412ec16c31623cbd6e5aa3d6efb1e;hpb=0c2687f44eb0e8c7f480b7303f89056682ba0bfb diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index 17f596d6b8..658b225b44 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -118,6 +118,9 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { /** @var int Key fetched */ private $warmupKeyMisses = 0; + /** @var float|null */ + private $wallClockOverride; + /** Max time expected to pass between delete() and DB commit finishing */ const MAX_COMMIT_DELAY = 3; /** Max replication+snapshot lag before applying TTL_LAGGED or disallowing set() */ @@ -2064,14 +2067,6 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { return isset( $parts[1] ) ? $parts[1] : $parts[0]; // sanity } - /** - * @return float UNIX timestamp - * @codeCoverageIgnore - */ - protected function getCurrentTime() { - return microtime( true ); - } - /** * @param string $value Wrapped value like "PURGED::" * @return array|bool Array containing a UNIX timestamp (float) and holdoff period (integer), @@ -2173,4 +2168,21 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { return $warmupCache; } + + /** + * @return float UNIX timestamp + * @codeCoverageIgnore + */ + protected function getCurrentTime() { + return $this->wallClockOverride ?: microtime( true ); + } + + /** + * @param float|null &$time Mock UNIX timestamp for testing + * @codeCoverageIgnore + */ + public function setMockTime( &$time ) { + $this->wallClockOverride =& $time; + $this->cache->setMockTime( $time ); + } }