* Remove pointless newline
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 22 May 2008 15:15:00 +0000 (15:15 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 22 May 2008 15:15:00 +0000 (15:15 +0000)
* It helps not to through fatal errors everywhere if not title
* Add optional $pageId param to getTimestampFromID() to avoid a secondary lookup, not that anything uses this function anyway...

includes/Revision.php

index 5b14e48..f801bed 100644 (file)
@@ -406,8 +406,7 @@ class Revision {
                               'rev_id' => $this->mId ),
                        'Revision::getTitle' );
                if( $row ) {
-                       $this->mTitle = Title::makeTitle( $row->page_namespace,
-                                                          $row->page_title );
+                       $this->mTitle = Title::makeTitle( $row->page_namespace, $row->page_title );
                }
                return $this->mTitle;
        }
@@ -558,7 +557,7 @@ class Revision {
         * @return Revision
         */
        public function getPrevious() {
-               $prev = $this->getTitle()->getPreviousRevisionID( $this->mId );
+               $prev = $this->getTitle() ? $this->getTitle()->getPreviousRevisionID( $this->mId ) : null;
                if( $prev ) {
                        return Revision::newFromTitle( $this->mTitle, $prev );
                } else {
@@ -570,7 +569,7 @@ class Revision {
         * @return Revision
         */
        public function getNext() {
-               $next = $this->getTitle()->getNextRevisionID( $this->mId );
+               $next = $this->getTitle() ? $this->getTitle()->getNextRevisionID( $this->mId ) : null;
                if ( $next ) {
                        return Revision::newFromTitle( $this->mTitle, $next );
                } else {
@@ -903,16 +902,19 @@ class Revision {
        /**
         * Get rev_timestamp from rev_id, without loading the rest of the row
         * @param integer $id
+        * @param integer $pageid, optional
         */
-       static function getTimestampFromID( $id ) {
+       static function getTimestampFromID( $id, $pageId = 0 ) {
                $dbr = wfGetDB( DB_SLAVE );
-               $timestamp = $dbr->selectField( 'revision', 'rev_timestamp',
-                       array( 'rev_id' => $id ), __METHOD__ );
+               $conds = array( 'rev_id' => $id );
+               if( $pageId ) {
+                       $conds['rev_page'] = $pageId;
+               }
+               $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );
                if ( $timestamp === false ) {
                        # Not in slave, try master
                        $dbw = wfGetDB( DB_MASTER );
-                       $timestamp = $dbw->selectField( 'revision', 'rev_timestamp',
-                               array( 'rev_id' => $id ), __METHOD__ );
+                       $timestamp = $dbw->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );
                }
                return $timestamp;
        }