]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/Revision.php
MediaWiki 1.15.0
[autoinstallsdev/mediawiki.git] / includes / Revision.php
index 7938d88a8d921137c093179be1c6467c7cccb3a8..8a2149c0de723c9ea9966bc94a8b4bf4898a8ad5 100644 (file)
@@ -53,6 +53,10 @@ class Revision {
                        // Get the latest revision ID from the master
                        $dbw = wfGetDB( DB_MASTER );
                        $latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ );
+                       if ( $latest === false ) {
+                               // Page does not exist
+                               return null;
+                       }
                        $conds['rev_id'] = $latest;
                } else {
                        // Use a join to get the latest revision
@@ -363,6 +367,7 @@ class Revision {
                } else {
                        throw new MWException( 'Revision constructor passed invalid row format.' );
                }
+               $this->mUnpatrolled = NULL;
        }
 
        /**#@+
@@ -536,6 +541,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
@@ -819,7 +845,8 @@ class Revision {
                                'rev_timestamp'  => $dbw->timestamp( $this->mTimestamp ),
                                'rev_deleted'    => $this->mDeleted,
                                'rev_len'            => $this->mSize,
-                               'rev_parent_id'  => $this->mParentId ? $this->mParentId : $this->getPreviousRevisionId( $dbw )
+                               'rev_parent_id'  => is_null($this->mParentId) ?
+                                       $this->getPreviousRevisionId( $dbw ) : $this->mParentId
                        ), __METHOD__
                );
 
@@ -961,6 +988,10 @@ class Revision {
         */
        static function getTimestampFromId( $title, $id ) {
                $dbr = wfGetDB( DB_SLAVE );
+               // Casting fix for DB2
+               if ($id == '') {
+                       $id = 0;
+               }
                $conds = array( 'rev_id' => $id );
                $conds['rev_page'] = $title->getArticleId();
                $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );