'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;
}
* @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 {
* @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 {
/**
* 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;
}