use Wikimedia\Rdbms\DBConnRef;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\ILoadBalancer;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
/**
* Service for looking up page revisions.
/**
* @var bool|string
*/
- private $wikiId;
+ private $dbDomain;
/**
* @var boolean
* @param ILoadBalancer $loadBalancer
* @param SqlBlobStore $blobStore
* @param WANObjectCache $cache A cache for caching revision rows. This can be the local
- * wiki's default instance even if $wikiId refers to a different wiki, since
+ * wiki's default instance even if $dbDomain refers to a different wiki, since
* makeGlobalKey() is used to constructed a key that allows cached revision rows from
* the same database to be re-used between wikis. For example, enwiki and frwiki will
* use the same cache keys for revision rows from the wikidatawiki database, regardless
* @param SlotRoleRegistry $slotRoleRegistry
* @param int $mcrMigrationStage An appropriate combination of SCHEMA_COMPAT_XXX flags
* @param ActorMigration $actorMigration
- * @param bool|string $wikiId
- *
+ * @param bool|string $dbDomain DB domain of the relevant wiki or false for the current one
*/
public function __construct(
ILoadBalancer $loadBalancer,
SlotRoleRegistry $slotRoleRegistry,
$mcrMigrationStage,
ActorMigration $actorMigration,
- $wikiId = false
+ $dbDomain = false
) {
- Assert::parameterType( 'string|boolean', $wikiId, '$wikiId' );
+ Assert::parameterType( 'string|boolean', $dbDomain, '$dbDomain' );
Assert::parameterType( 'integer', $mcrMigrationStage, '$mcrMigrationStage' );
Assert::parameter(
( $mcrMigrationStage & SCHEMA_COMPAT_READ_BOTH ) !== SCHEMA_COMPAT_READ_BOTH,
$this->slotRoleRegistry = $slotRoleRegistry;
$this->mcrMigrationStage = $mcrMigrationStage;
$this->actorMigration = $actorMigration;
- $this->wikiId = $wikiId;
+ $this->dbDomain = $dbDomain;
$this->logger = new NullLogger();
}
* @throws RevisionAccessException
*/
private function assertCrossWikiContentLoadingIsSafe() {
- if ( $this->wikiId !== false && $this->hasMcrSchemaFlags( SCHEMA_COMPAT_READ_OLD ) ) {
+ if ( $this->dbDomain !== false && $this->hasMcrSchemaFlags( SCHEMA_COMPAT_READ_OLD ) ) {
throw new RevisionAccessException(
"Cross-wiki content loading is not supported by the pre-MCR schema"
);
*/
private function getDBConnection( $mode, $groups = [] ) {
$lb = $this->getDBLoadBalancer();
- return $lb->getConnection( $mode, $groups, $this->wikiId );
+ return $lb->getConnection( $mode, $groups, $this->dbDomain );
}
/**
*/
private function getDBConnectionRef( $mode ) {
$lb = $this->getDBLoadBalancer();
- return $lb->getConnectionRef( $mode, [], $this->wikiId );
+ return $lb->getConnectionRef( $mode, [], $this->dbDomain );
}
/**
$queryFlags = self::READ_NORMAL;
}
- $canUseTitleNewFromId = ( $pageId !== null && $pageId > 0 && $this->wikiId === false );
+ $canUseTitleNewFromId = ( $pageId !== null && $pageId > 0 && $this->dbDomain === false );
list( $dbMode, $dbOptions ) = DBAccessObjectUtils::getDBOptions( $queryFlags );
$titleFlags = ( $dbMode == DB_MASTER ? Title::GAID_FOR_UPDATE : 0 );
$comment,
(object)$revisionRow,
new RevisionSlots( $newSlots ),
- $this->wikiId
+ $this->dbDomain
);
return $rev;
throw new MWException( 'Failed to get database lock for T202032' );
}
$fname = __METHOD__;
- $dbw->onTransactionResolution( function ( $trigger, $dbw ) use ( $fname ) {
- $dbw->unlock( 'fix-for-T202032', $fname );
- } );
+ $dbw->onTransactionResolution(
+ function ( $trigger, IDatabase $dbw ) use ( $fname ) {
+ $dbw->unlock( 'fix-for-T202032', $fname );
+ }
+ );
$dbw->delete( 'revision', [ 'rev_id' => $revisionRow['rev_id'] ], __METHOD__ );
* Factory method for SlotRecords based on known slot rows.
*
* @param int $revId The revision to load slots for.
- * @param object[]|ResultWrapper $slotRows
+ * @param object[]|IResultWrapper $slotRows
* @param int $queryFlags
* @param Title $title
*
$row->ar_user ?? null,
$row->ar_user_text ?? null,
$row->ar_actor ?? null,
- $this->wikiId
+ $this->dbDomain
);
} catch ( InvalidArgumentException $ex ) {
wfWarn( __METHOD__ . ': ' . $title->getPrefixedDBkey() . ': ' . $ex->getMessage() );
$slots = $this->newRevisionSlots( $row->ar_rev_id, $row, null, $queryFlags, $title );
- return new RevisionArchiveRecord( $title, $user, $comment, $row, $slots, $this->wikiId );
+ return new RevisionArchiveRecord( $title, $user, $comment, $row, $slots, $this->dbDomain );
}
/**
$row->rev_user ?? null,
$row->rev_user_text ?? null,
$row->rev_actor ?? null,
- $this->wikiId
+ $this->dbDomain
);
} catch ( InvalidArgumentException $ex ) {
wfWarn( __METHOD__ . ': ' . $title->getPrefixedDBkey() . ': ' . $ex->getMessage() );
[ 'rev_id' => intval( $revId ) ]
);
},
- $title, $user, $comment, $row, $slots, $this->wikiId
+ $title, $user, $comment, $row, $slots, $this->dbDomain
);
} else {
$rev = new RevisionStoreRecord(
- $title, $user, $comment, $row, $slots, $this->wikiId );
+ $title, $user, $comment, $row, $slots, $this->dbDomain );
}
return $rev;
}
}
}
- $revision = new MutableRevisionRecord( $title, $this->wikiId );
+ $revision = new MutableRevisionRecord( $title, $this->dbDomain );
$this->initializeMutableRevisionFromArray( $revision, $fields );
if ( isset( $fields['content'] ) && is_array( $fields['content'] ) ) {
// remote wiki with unsuppressed ids, due to issues described in T222212.
if ( isset( $fields['user'] ) &&
( $fields['user'] instanceof UserIdentity ) &&
- ( $this->wikiId === false ||
+ ( $this->dbDomain === false ||
( !$fields['user']->getId() && !$fields['user']->getActorId() ) )
) {
$user = $fields['user'];
$fields['user'] ?? null,
$fields['user_text'] ?? null,
$fields['actor'] ?? null,
- $this->wikiId
+ $this->dbDomain
);
} catch ( InvalidArgumentException $ex ) {
$user = null;
* @throws MWException
*/
private function checkDatabaseWikiId( IDatabase $db ) {
- $storeWiki = $this->wikiId;
+ $storeWiki = $this->dbDomain;
$dbWiki = $db->getDomainID();
if ( $dbWiki === $storeWiki ) {