return;
}
- if ( $from === self::READ_LOCKING ) {
- $data = $this->pageDataFromTitle( wfGetDB( DB_MASTER ), $this->mTitle, array( 'FOR UPDATE' ) );
- } elseif ( $from === self::READ_LATEST ) {
- $data = $this->pageDataFromTitle( wfGetDB( DB_MASTER ), $this->mTitle );
- } elseif ( $from === self::READ_NORMAL ) {
- $data = $this->pageDataFromTitle( wfGetDB( DB_SLAVE ), $this->mTitle );
+ if ( is_int( $from ) ) {
+ list( $index, $opts ) = DBAccessObjectUtils::getDBOptions( $from );
+ $data = $this->pageDataFromTitle( wfGetDB( $index ), $this->mTitle, $opts );
+
if ( !$data
+ && $index == DB_SLAVE
&& wfGetLB()->getServerCount() > 1
&& wfGetLB()->hasOrMadeRecentMasterChanges()
) {
$from = self::READ_LATEST;
- $data = $this->pageDataFromTitle( wfGetDB( DB_MASTER ), $this->mTitle );
+ list( $index, $opts ) = DBAccessObjectUtils::getDBOptions( $from );
+ $data = $this->pageDataFromTitle( wfGetDB( $index ), $this->mTitle, $opts );
}
} else {
// No idea from where the caller got this data, assume slave database.
* Best if all done inside a transaction.
*
* @param DatabaseBase $dbw
- * @return int The newly created page_id key, or false if the title already existed
+ * @return int|bool The newly created page_id key; false if the title already existed
*/
public function insertOn( $dbw ) {
-
$page_id = $dbw->nextSequenceValue( 'page_page_id_seq' );
$dbw->insert( 'page', array(
'page_id' => $page_id,
$newid = $dbw->insertId();
$this->mId = $newid;
$this->mTitle->resetArticleID( $newid );
- }
- return $affected ? $newid : false;
+ return $newid;
+ } else {
+ return false;
+ }
}
/**
// Purge squid for this page only
$title->purgeSquid();
-
- $revid = $revision ? $revision->getId() : null;
// Clear file cache for this page only
HTMLFileCache::clearFileCache( $title );
+
+ $revid = $revision ? $revision->getId() : null;
DeferredUpdates::addCallableUpdate( function() use ( $title, $revid ) {
InfoAction::invalidateCache( $title, $revid );
} );