Add cache versioning to InfoAction.
authorTyler Anthony Romeo <tylerromeo@gmail.com>
Sun, 17 Mar 2013 04:39:40 +0000 (00:39 -0400)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 24 May 2013 19:38:01 +0000 (19:38 +0000)
To avoid PHP notices, add a cache version key to
the page count cache so that it is invalidated
when the InfoAction cache format is changed.

Bug: 43766
Change-Id: I7fe4da351506d8b98490e9fbbeb51c2c081fc2a8

includes/actions/InfoAction.php

index 7cd1f72..f46314a 100644 (file)
@@ -28,6 +28,8 @@
  * @ingroup Actions
  */
 class InfoAction extends FormlessAction {
+       const CACHE_VERSION = '2013-03-17';
+
        /**
         * Returns the name of the action this object responds to.
         *
@@ -194,9 +196,11 @@ class InfoAction extends FormlessAction {
 
                $memcKey = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $this->page->getLatest() );
                $pageCounts = $wgMemc->get( $memcKey );
-               if ( $pageCounts === false ) {
+               $version = isset( $pageCounts['cacheversion'] ) ? $pageCounts['cacheversion'] : false;
+               if ( $pageCounts === false || $version !== self::CACHE_VERSION ) {
                        // Get page information that would be too "expensive" to retrieve by normal means
                        $pageCounts = self::pageCounts( $title );
+                       $pageCounts['cacheversion'] = self::CACHE_VERSION;
 
                        $wgMemc->set( $memcKey, $pageCounts );
                }