Fixed ParserCache IDE warnings
[lhc/web/wiklou.git] / includes / parser / ParserCache.php
index 16dde0d..47fcd30 100644 (file)
@@ -26,7 +26,7 @@
  * @todo document
  */
 class ParserCache {
-       /** @var MWMemcached */
+       /** @var BagOStuff */
        private $mMemc;
        /**
         * Get an instance of this object
@@ -46,7 +46,7 @@ class ParserCache {
         * Setup a cache pathway with a given back-end storage mechanism.
         * May be a memcached client or a BagOStuff derivative.
         *
-        * @param MWMemcached $memCached
+        * @param BagOStuff $memCached
         * @throws MWException
         */
        protected function __construct( $memCached ) {
@@ -176,7 +176,7 @@ class ParserCache {
         * Retrieve the ParserOutput from ParserCache.
         * false if not found or outdated.
         *
-        * @param WikiPage $article
+        * @param WikiPage|Article $article
         * @param ParserOptions $popts
         * @param bool $useOutdated (default false)
         *
@@ -213,6 +213,10 @@ class ParserCache {
                // key. Force it here. See bug 31445.
                $value->setEditSectionTokens( $popts->getEditSection() );
 
+               $wikiPage = method_exists( $article, 'getPage' )
+                       ? $article->getPage()
+                       : $article;
+
                if ( !$useOutdated && $value->expired( $touched ) ) {
                        wfIncrStats( "pcache.miss.expired" );
                        $cacheTime = $value->getCacheTime();
@@ -225,6 +229,10 @@ class ParserCache {
                        $cachedRevId = $value->getCacheRevisionId();
                        wfDebug( "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n" );
                        $value = false;
+               } elseif ( Hooks::run( 'RejectParserCacheValue', array( $value, $wikiPage, $popts ) ) === false ) {
+                       wfIncrStats( 'pcache.miss.rejected' );
+                       wfDebug( "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n" );
+                       $value = false;
                } else {
                        wfIncrStats( "pcache.hit" );
                }