Bug: T92357
Change-Id: Id5cf7a5620daeee12abfa778f9be19435f3e5e84
*
* @param Title $title
* @param int $id
*
* @param Title $title
* @param int $id
+ * @return string|bool False if not found
- static function getTimestampFromId( $title, $id ) {
- $dbr = wfGetDB( DB_SLAVE );
+ static function getTimestampFromId( $title, $id, $flags = 0 ) {
+ $db = ( $flags & self::READ_LATEST )
+ ? wfGetDB( DB_MASTER )
+ : wfGetDB( DB_SLAVE );
// Casting fix for databases that can't take '' for rev_id
if ( $id == '' ) {
$id = 0;
}
$conds = array( 'rev_id' => $id );
$conds['rev_page'] = $title->getArticleID();
// Casting fix for databases that can't take '' for rev_id
if ( $id == '' ) {
$id = 0;
}
$conds = array( 'rev_id' => $id );
$conds['rev_page'] = $title->getArticleID();
- $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );
- if ( $timestamp === false && wfGetLB()->getServerCount() > 1 ) {
- # Not in slave, try master
- $dbw = wfGetDB( DB_MASTER );
- $timestamp = $dbw->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );
- }
- return wfTimestamp( TS_MW, $timestamp );
+ $timestamp = $db->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );
+
+ return ( $timestamp !== false ) ? wfTimestamp( TS_MW, $timestamp ) : false;
}
$title = reset( $pageSet->getGoodTitles() );
if ( $title ) {
}
$title = reset( $pageSet->getGoodTitles() );
if ( $title ) {
- $timestamp = Revision::getTimestampFromId( $title, $params['torevid'] );
+ $timestamp = Revision::getTimestampFromId(
+ $title, $params['torevid'], Revision::READ_LATEST );
if ( $timestamp ) {
$timestamp = $dbw->timestamp( $timestamp );
} else {
if ( $timestamp ) {
$timestamp = $dbw->timestamp( $timestamp );
} else {
}
$title = reset( $pageSet->getGoodTitles() );
if ( $title ) {
}
$title = reset( $pageSet->getGoodTitles() );
if ( $title ) {
- $revid = $title->getNextRevisionID( $params['newerthanrevid'] );
+ $revid = $title->getNextRevisionID(
+ $params['newerthanrevid'], Title::GAID_FOR_UPDATE );
if ( $revid ) {
$timestamp = $dbw->timestamp( Revision::getTimestampFromId( $title, $revid ) );
} else {
if ( $revid ) {
$timestamp = $dbw->timestamp( Revision::getTimestampFromId( $title, $revid ) );
} else {