$mp = new MovePage( $oldSubpage, $newSubpage );
$method = $checkPermissions ? 'moveIfAllowed' : 'move';
+ /** @var Status $status */
$status = $mp->$method( $user, $reason, $createRedirect, $changeTags );
if ( $status->isOK() ) {
$status->setResult( true, $newSubpage->getPrefixedText() );
Hooks::run( 'TitleMoveStarting', [ $this->oldTitle, $this->newTitle, $user ] );
- $pageid = $this->oldTitle->getArticleID( Title::GAID_FOR_UPDATE );
+ $pageid = $this->oldTitle->getArticleID( Title::READ_LATEST );
$protected = $this->oldTitle->isProtected();
// Do the actual move; if this fails, it will throw an MWException(!)
$comment = CommentStoreComment::newUnsavedComment( $summary, null );
- $title = Title::newFromID( $pageId, Title::GAID_FOR_UPDATE );
+ $title = Title::newFromID( $pageId, Title::READ_LATEST );
if ( $title === null ) {
return null;
}
$canUseTitleNewFromId = ( $pageId !== null && $pageId > 0 && $this->dbDomain === false );
list( $dbMode, $dbOptions ) = DBAccessObjectUtils::getDBOptions( $queryFlags );
- $titleFlags = ( $dbMode == DB_MASTER ? Title::GAID_FOR_UPDATE : 0 );
// Loading by ID is best, but Title::newFromID does not support that for foreign IDs.
if ( $canUseTitleNewFromId ) {
+ $titleFlags = ( $dbMode == DB_MASTER ? Title::READ_LATEST : 0 );
// TODO: better foreign title handling (introduce TitleFactory)
$title = Title::newFromID( $pageId, $titleFlags );
if ( $title ) {
$titles = $pageSet->getGoodTitles();
$title = reset( $titles );
if ( $title ) {
- $revid = $title->getNextRevisionID( $params['newerthanrevid'], Title::GAID_FOR_UPDATE );
+ $revid = $title->getNextRevisionID( $params['newerthanrevid'], Title::READ_LATEST );
if ( $revid ) {
$timestamp = $dbw->timestamp(
MediaWikiServices::getInstance()->getRevisionStore()->getTimestampFromId( $title, $revid )
*
* @param bool|null $update
* @return bool
+ * @deprecated Since 1.34
*/
public function forUpdate( $update = null ) {
return wfSetVar( $this->mForUpdate, $update );
* This will work on any MediaWiki installation.
*/
class LCStoreDB implements LCStore {
- /** @var string */
- private $currentLang;
- /** @var bool */
- private $writesDone = false;
+ /** @var string Language code */
+ private $code;
+ /** @var array Server configuration map */
+ private $server;
+
+ /** @var array Rows buffered for insertion */
+ private $batch = [];
+
/** @var IDatabase|null */
private $dbw;
- /** @var array */
- private $batch = [];
- /** @var bool */
+ /** @var bool Whether a batch of writes were recently written */
+ private $writesDone = false;
+ /** @var bool Whether the DB is read-only or otherwise unavailable for writes */
private $readOnly = false;
- /** @var array Server configuration map */
- private $server;
public function __construct( $params ) {
$this->server = $params['server'] ?? [];
$dbw = $this->getWriteConnection();
$this->readOnly = $dbw->isReadOnly();
- $this->currentLang = $code;
+ $this->code = $code;
$this->batch = [];
}
public function finishWrite() {
if ( $this->readOnly ) {
return;
- } elseif ( is_null( $this->currentLang ) ) {
+ } elseif ( is_null( $this->code ) ) {
throw new MWException( __CLASS__ . ': must call startWrite() before finishWrite()' );
}
$dbw = $this->getWriteConnection();
$dbw->startAtomic( __METHOD__ );
try {
- $dbw->delete( 'l10n_cache', [ 'lc_lang' => $this->currentLang ], __METHOD__ );
+ $dbw->delete( 'l10n_cache', [ 'lc_lang' => $this->code ], __METHOD__ );
foreach ( array_chunk( $this->batch, 500 ) as $rows ) {
$dbw->insert( 'l10n_cache', $rows, __METHOD__ );
}
$trxProfiler->setSilenced( $oldSilenced );
}
- $this->currentLang = null;
+ $this->code = null;
$this->batch = [];
}
public function set( $key, $value ) {
if ( $this->readOnly ) {
return;
- } elseif ( is_null( $this->currentLang ) ) {
+ } elseif ( is_null( $this->code ) ) {
throw new MWException( __CLASS__ . ': must call startWrite() before set()' );
}
$dbw = $this->getWriteConnection();
$this->batch[] = [
- 'lc_lang' => $this->currentLang,
+ 'lc_lang' => $this->code,
'lc_key' => $key,
'lc_value' => $dbw->encodeBlob( serialize( $value ) )
];
if ( !$this->mId ) {
// NOTE: subclasses may initialize mId before calling this constructor!
- $this->mId = $title->getArticleID( Title::GAID_FOR_UPDATE );
+ $this->mId = $title->getArticleID( Title::READ_LATEST );
}
if ( !$this->mId ) {
$title = $page->getTitle();
// Get the latest ID since acquirePageLock() in runForTitle() flushed the transaction.
// This is used to detect edits/moves after loadPageData() but before the scope lock.
- // The works around the chicken/egg problem of determining the scope lock key name.
- $latest = $title->getLatestRevID( Title::GAID_FOR_UPDATE );
+ // The works around the chicken/egg problem of determining the scope lock key name
+ $latest = $title->getLatestRevID( Title::READ_LATEST );
$triggeringRevisionId = $this->params['triggeringRevisionId'] ?? null;
if ( $triggeringRevisionId && $triggeringRevisionId !== $latest ) {
// Validate and sanitize the relative path (backend-specific)
$relPath = $this->resolveContainerPath( $shortCont, $relPath );
if ( $relPath !== null ) {
- // Prepend any wiki ID prefix to the container name
+ // Prepend any domain ID prefix to the container name
$container = $this->fullContainerName( $shortCont );
if ( self::isValidContainerName( $container ) ) {
// Validate and sanitize the container name (backend-specific)
}
/**
- * Get the full container name, including the wiki ID prefix
+ * Get the full container name, including the domain ID prefix
*
* @param string $container
* @return string
/** @var array */
public $resourcesToClose = [];
- public $call; // string; name that identifies the function called
-
/**
* Close all open file handles
*/
// Try using the replica DB first, then try the master
$rev = $this->mTitle->getFirstRevision();
if ( !$rev ) {
- $rev = $this->mTitle->getFirstRevision( Title::GAID_FOR_UPDATE );
+ $rev = $this->mTitle->getFirstRevision( Title::READ_LATEST );
}
return $rev;
}
// If there is a new, unseen, revision, use its timestamp
$nextid = $oldid
- ? $title->getNextRevisionID( $oldid, Title::GAID_FOR_UPDATE )
+ ? $title->getNextRevisionID( $oldid, Title::READ_LATEST )
: null;
if ( $nextid ) {
$this->setNewtalk( true, Revision::newFromId( $nextid ) );
* @param Title $title
*/
protected function moveInconsistentPage( $row, Title $title ) {
- if ( $title->exists( Title::GAID_FOR_UPDATE )
+ if ( $title->exists( Title::READ_LATEST )
|| $title->getInterwiki()
|| !$title->canExist()
) {
$this->assertEquals(
false,
$title->exists(),
- 'exists() should rely on link cache unless GAID_FOR_UPDATE is used'
+ 'exists() should rely on link cache unless READ_LATEST is used'
);
$this->assertEquals(
true,
- $title->exists( Title::GAID_FOR_UPDATE ),
- 'exists() should re-query database when GAID_FOR_UPDATE is used'
+ $title->exists( Title::READ_LATEST ),
+ 'exists() should re-query database when READ_LATEST is used'
);
}
$jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
$jobs->execute();
- $this->assertFalse( Title::newFromText( $name )->exists( Title::GAID_FOR_UPDATE ) );
+ $this->assertFalse( Title::newFromText( $name )->exists( Title::READ_LATEST ) );
}
public function testDeleteNonexistent() {
// Make a few edits for us to play with
for ( $i = 1; $i <= 5; $i++ ) {
self::editPage( self::$page, MWCryptRand::generateHex( 10 ), 'summary' );
- $this->revs[] = Title::newFromText( self::$page )
- ->getLatestRevID( Title::GAID_FOR_UPDATE );
+ $this->revs[] = Title::newFromText( self::$page )->getLatestRevID( Title::READ_LATEST );
}
}