Avoid unneeded memcached queries in showPatrolFooter()
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 17 Sep 2015 18:28:53 +0000 (11:28 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 17 Sep 2015 18:50:22 +0000 (11:50 -0700)
Change-Id: I395019e85cbc80df7d77183ccb75b3691949efc6

includes/page/Article.php

index 120aa5c..29a38ba 100644 (file)
@@ -1091,11 +1091,6 @@ class Article implements Page {
                // to get the recentchanges row belonging to that entry
                // (with rc_new = 1).
 
-               // Check for cached results
-               if ( $cache->get( wfMemcKey( 'NotPatrollablePage', $this->getTitle()->getArticleID() ) ) ) {
-                       return false;
-               }
-
                if ( $this->mRevision
                        && !RecentChange::isInRCLifespan( $this->mRevision->getTimestamp(), 21600 )
                ) {
@@ -1104,6 +1099,12 @@ class Article implements Page {
                        return false;
                }
 
+               // Check for cached results
+               $key = wfMemcKey( 'NotPatrollablePage', $this->getTitle()->getArticleID() );
+               if ( $cache->get( $key ) ) {
+                       return false;
+               }
+
                $dbr = wfGetDB( DB_SLAVE );
                $oldestRevisionTimestamp = $dbr->selectField(
                        'revision',
@@ -1129,7 +1130,7 @@ class Article implements Page {
                } else {
                        // Cache the information we gathered above in case we can't patrol
                        // Don't cache in case we can patrol as this could change
-                       $cache->set( wfMemcKey( 'NotPatrollablePage', $this->getTitle()->getArticleID() ), '1' );
+                       $cache->set( $key, '1' );
                }
 
                if ( !$rc ) {
@@ -1144,7 +1145,7 @@ class Article implements Page {
 
                        // Cache the information we gathered above in case we can't patrol
                        // Don't cache in case we can patrol as this could change
-                       $cache->set( wfMemcKey( 'NotPatrollablePage', $this->getTitle()->getArticleID() ), '1' );
+                       $cache->set( $key, '1' );
 
                        return false;
                }