* 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...
This commit is contained in:
parent
b690c9ac4d
commit
3e36ba655e
1 changed files with 11 additions and 9 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue