From 23ae30d61cca3148451d0b1971d2d466fb6aebad Mon Sep 17 00:00:00 2001 From: Kevin Israel Date: Sun, 25 Oct 2015 21:29:47 -0400 Subject: [PATCH] Preprocessor: Use correct cache prefix for the subclass Follows-up 1559be9f7aef, which caused "Preprocessor" to be used as the cache prefix for all subclasses, by using late static binding to access the constant. Though use of that feature has been discouraged[1], this change is a straightforward bug fix, and any improvements can be made separately. [1]: https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#Late_static_binding Change-Id: Ib25e1908a6373f6675659a0906e12d4a38af014c --- includes/parser/Preprocessor.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/parser/Preprocessor.php b/includes/parser/Preprocessor.php index 30eab19a57..b1e49b2a6f 100644 --- a/includes/parser/Preprocessor.php +++ b/includes/parser/Preprocessor.php @@ -46,9 +46,11 @@ abstract class Preprocessor { } $key = wfMemcKey( - defined( 'self::CACHE_PREFIX' ) ? self::CACHE_PREFIX : __CLASS__, + // TODO: Once we require PHP 5.5, use static::class instead of + // get_called_class() or get_class( $this ). + defined( 'static::CACHE_PREFIX' ) ? static::CACHE_PREFIX : get_called_class(), md5( $text ), $flags ); - $value = sprintf( "%08d", self::CACHE_VERSION ) . $tree; + $value = sprintf( "%08d", static::CACHE_VERSION ) . $tree; $cache = ObjectCache::getInstance( $config->get( 'MainCacheType' ) ); $cache->set( $key, $value, 86400 ); @@ -77,7 +79,9 @@ abstract class Preprocessor { $cache = ObjectCache::getInstance( $config->get( 'MainCacheType' ) ); $key = wfMemcKey( - defined( 'self::CACHE_PREFIX' ) ? self::CACHE_PREFIX : __CLASS__, + // TODO: Once we require PHP 5.5, use static::class instead of + // get_called_class() or get_class( $this ). + defined( 'static::CACHE_PREFIX' ) ? static::CACHE_PREFIX : get_called_class(), md5( $text ), $flags ); $value = $cache->get( $key ); @@ -86,7 +90,7 @@ abstract class Preprocessor { } $version = intval( substr( $value, 0, 8 ) ); - if ( $version !== self::CACHE_VERSION ) { + if ( $version !== static::CACHE_VERSION ) { return false; } -- 2.20.1