From 3e36ba655e3a6a6b1da949bc77d1e7df5cf56027 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 22 May 2008 15:15:00 +0000 Subject: [PATCH] * Remove pointless newline * 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 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/includes/Revision.php b/includes/Revision.php index 5b14e48a3d..f801bed79c 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -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; } -- 2.20.1