X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2Fobjectcache%2Fwancache%2FWANObjectCache.php;h=70f35532d2899c47e95295ee0a8b7d0534a62a3b;hp=2ce216d08a131c9f9871bad4f68f88b866350c57;hb=a1ef77b2d80830fbcb617a83961d78cff9d6e384;hpb=a389d94551f1ece9112c66bf8a53f66d3c15c0b2 diff --git a/includes/libs/objectcache/wancache/WANObjectCache.php b/includes/libs/objectcache/wancache/WANObjectCache.php index 2ce216d08a..70f35532d2 100644 --- a/includes/libs/objectcache/wancache/WANObjectCache.php +++ b/includes/libs/objectcache/wancache/WANObjectCache.php @@ -125,7 +125,7 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt /** @var callable|null Function that takes a WAN cache callback and runs it later */ protected $asyncHandler; - /** @bar bool Whether to use mcrouter key prefixing for routing */ + /** @var bool Whether to use mcrouter key prefixing for routing */ protected $mcrouterAware; /** @var string Physical region for mcrouter use */ protected $region; @@ -585,7 +585,6 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt * @note Options added in 1.33: creating * @note Options added in 1.34: version, walltime * @return bool Success - * @suppress PhanTypeInvalidDimOffset */ final public function set( $key, $value, $ttl = self::TTL_INDEFINITE, array $opts = [] ) { $now = $this->getCurrentTime(); @@ -1258,7 +1257,6 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt * @note Options added in 1.31: staleTTL, graceTTL * @note Options added in 1.33: touchedCallback * @note Callable type hints are not used to avoid class-autoloading - * @suppress PhanTypeInvalidDimOffset */ final public function getWithSetCallback( $key, $ttl, $callback, array $opts = [] ) { $version = $opts['version'] ?? null; @@ -1450,7 +1448,6 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt $this->setInterimValue( $key, $value, $lockTSE, $version, $walltime ); } else { $finalSetOpts = [ - // @phan-suppress-next-line PhanTypeInvalidDimOffset 'since' => $setOpts['since'] ?? $preCallbackTime, 'version' => $version, 'staleTTL' => $staleTTL, @@ -2328,6 +2325,7 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt $chance = ( 1 - $curTTL / $lowTTL ); + // @phan-suppress-next-line PhanTypeMismatchArgumentInternal return mt_rand( 1, 1e9 ) <= 1e9 * $chance; } @@ -2370,6 +2368,7 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt // Ramp up $chance from 0 to its nominal value over RAMPUP_TTL seconds to avoid stampedes $chance *= ( $timeOld <= self::$RAMPUP_TTL ) ? $timeOld / self::$RAMPUP_TTL : 1; + // @phan-suppress-next-line PhanTypeMismatchArgumentInternal return mt_rand( 1, 1e9 ) <= 1e9 * $chance; } @@ -2489,8 +2488,9 @@ class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInt */ private function determineKeyClassForStats( $key ) { $parts = explode( ':', $key, 3 ); - - return $parts[1] ?? $parts[0]; // sanity + // Sanity fallback in case the key was not made by makeKey. + // Replace dots because they are special in StatsD (T232907) + return strtr( $parts[1] ?? $parts[0], '.', '_' ); } /**