Merge "Don't check namespace in SpecialWantedtemplates"
[lhc/web/wiklou.git] / includes / page / Article.php
index 54db19c..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',
@@ -1121,20 +1122,30 @@ class Article implements Page {
                                        'rc_new' => 1,
                                        'rc_timestamp' => $oldestRevisionTimestamp,
                                        'rc_namespace' => $this->getTitle()->getNamespace(),
-                                       'rc_cur_id' => $this->getTitle()->getArticleID(),
-                                       'rc_patrolled' => 0
+                                       'rc_cur_id' => $this->getTitle()->getArticleID()
                                ),
                                __METHOD__,
                                array( 'USE INDEX' => 'new_name_timestamp' )
                        );
+               } 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( $key, '1' );
                }
 
                if ( !$rc ) {
-                       // No RC entry around
+                       // Don't cache: This can be hit if the page gets accessed very fast after
+                       // its creation or in case we have high slave lag. In case the revision is
+                       // too old, we will already return above.
+                       return false;
+               }
+
+               if ( $rc->getAttribute( 'rc_patrolled' ) ) {
+                       // Patrolled RC entry around
 
                        // 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;
                }