From: jenkins-bot Date: Wed, 18 Sep 2019 02:54:32 +0000 (+0000) Subject: Merge "objectcache: Escape dots from cache keys in StatsD metrics" X-Git-Tag: 1.34.0-rc.0~171 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=88d9cc22d31b526b309c163b62b1899c813c63aa;hp=260a734173bcc6b414aafb92de559505fe47bafc Merge "objectcache: Escape dots from cache keys in StatsD metrics" --- diff --git a/includes/libs/objectcache/wancache/WANObjectCache.php b/includes/libs/objectcache/wancache/WANObjectCache.php index 629d2cdcaf..70f35532d2 100644 --- a/includes/libs/objectcache/wancache/WANObjectCache.php +++ b/includes/libs/objectcache/wancache/WANObjectCache.php @@ -2488,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], '.', '_' ); } /** diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index ac988e6467..076bf5229d 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -1981,6 +1981,8 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { [ 'domain:page:5', 'page' ], [ 'domain:main-key', 'main-key' ], [ 'domain:page:history', 'page' ], + // Regression test for T232907 + [ 'domain:foo-bar-1.2:abc:v2', 'foo-bar-1_2' ], [ 'missingdomainkey', 'missingdomainkey' ] ]; }