(Bug 15936) New page's patrol button should always be visible
[lhc/web/wiklou.git] / includes / Revision.php
index 5fef68c..458b312 100644 (file)
@@ -363,6 +363,7 @@ class Revision {
                } else {
                        throw new MWException( 'Revision constructor passed invalid row format.' );
                }
+               $this->mUnpatrolled = NULL;
        }
 
        /**#@+
@@ -536,6 +537,27 @@ class Revision {
        public function isMinor() {
                return (bool)$this->mMinorEdit;
        }
+       
+       /**
+        * @return int rcid of the unpatrolled row, zero if there isn't one
+        */
+       public function isUnpatrolled() {
+               if( $this->mUnpatrolled !== NULL ) {
+                       return $this->mUnpatrolled;
+               }
+               $dbr = wfGetDB( DB_SLAVE );
+               $this->mUnpatrolled = $dbr->selectField( 'recentchanges',
+                       'rc_id',
+                       array( // Add redundant user,timestamp condition so we can use the existing index
+                               'rc_user_text'  => $this->getRawUserText(),
+                               'rc_timestamp'  => $dbr->timestamp( $this->getTimestamp() ),
+                               'rc_this_oldid' => $this->getId(),
+                               'rc_patrolled'  => 0
+                       ),
+                       __METHOD__
+               );
+               return (int)$this->mUnpatrolled;
+       }
 
        /**
         * int $field one of DELETED_* bitfield constants