*/
$wgActorTableSchemaMigrationStage = SCHEMA_COMPAT_OLD;
-/**
- * change_tag table schema migration stage.
- *
- * - MIGRATION_OLD: Do not use change_tag_def table or ct_tag_id.
- * - MIGRATION_WRITE_BOTH: Write to the change_tag_def table and ct_tag_id, but read from
- * the old schema. This is different from the formal definition of the constants
- * - MIGRATION_WRITE_NEW: Behaves the same as MIGRATION_WRITE_BOTH
- * - MIGRATION_NEW: Use the change_tag_def table and ct_tag_id, do not read/write ct_tag
- *
- * @since 1.32
- * @var int One of the MIGRATION_* constants
- */
-$wgChangeTagsSchemaMigrationStage = MIGRATION_NEW;
-
/**
* Flag to enable Partial Blocks. This allows an admin to prevent a user from editing specific pages
* or namespaces.
* @return void
*/
protected function run( ApiPageSet $resultPageSet = null ) {
- global $wgChangeTagsSchemaMigrationStage;
-
// Before doing anything at all, let's check permissions
$this->checkUserRightsAny( 'deletedhistory' );
$this->addJoinConds(
[ 'change_tag' => [ 'INNER JOIN', [ 'ar_rev_id=ct_rev_id' ] ] ]
);
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
- try {
- $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
- } catch ( NameTableAccessException $exception ) {
- // Return nothing.
- $this->addWhere( '1=0' );
- }
- } else {
- $this->addWhereFld( 'ct_tag', $params['tag'] );
+ $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+ try {
+ $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+ } catch ( NameTableAccessException $exception ) {
+ // Return nothing.
+ $this->addWhere( '1=0' );
}
}
}
protected function run( ApiPageSet $resultPageSet = null ) {
- global $wgChangeTagsSchemaMigrationStage;
-
$user = $this->getUser();
// Before doing anything at all, let's check permissions
$this->checkUserRightsAny( 'deletedhistory' );
$this->addJoinConds(
[ 'change_tag' => [ 'INNER JOIN', [ 'ar_rev_id=ct_rev_id' ] ] ]
);
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
- try {
- $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
- } catch ( NameTableAccessException $exception ) {
- // Return nothing.
- $this->addWhere( '1=0' );
- }
- } else {
- $this->addWhereFld( 'ct_tag', $params['tag'] );
+ $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+ try {
+ $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+ } catch ( NameTableAccessException $exception ) {
+ // Return nothing.
+ $this->addWhere( '1=0' );
}
}
}
public function execute() {
- global $wgChangeTagsSchemaMigrationStage;
-
// Before doing anything at all, let's check permissions
$this->checkUserRightsAny( 'deletedhistory' );
$this->addJoinConds(
[ 'change_tag' => [ 'INNER JOIN', [ 'ar_rev_id=ct_rev_id' ] ] ]
);
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
- try {
- $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
- } catch ( NameTableAccessException $exception ) {
- // Return nothing.
- $this->addWhere( '1=0' );
- }
- } else {
- $this->addWhereFld( 'ct_tag', $params['tag'] );
+ $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+ try {
+ $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+ } catch ( NameTableAccessException $exception ) {
+ // Return nothing.
+ $this->addWhere( '1=0' );
}
}
$fld_details = false, $fld_tags = false;
public function execute() {
- global $wgChangeTagsSchemaMigrationStage;
-
$params = $this->extractRequestParams();
$db = $this->getDB();
$this->commentStore = CommentStore::getStore();
$this->addTables( 'change_tag' );
$this->addJoinConds( [ 'change_tag' => [ 'INNER JOIN',
[ 'log_id=ct_log_id' ] ] ] );
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
- try {
- $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
- } catch ( NameTableAccessException $exception ) {
- // Return nothing.
- $this->addWhere( '1=0' );
- }
- } else {
- $this->addWhereFld( 'ct_tag', $params['tag'] );
+ $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+ try {
+ $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+ } catch ( NameTableAccessException $exception ) {
+ // Return nothing.
+ $this->addWhere( '1=0' );
}
}
* @param ApiPageSet|null $resultPageSet
*/
public function run( $resultPageSet = null ) {
- global $wgChangeTagsSchemaMigrationStage;
-
$user = $this->getUser();
/* Get the parameters of the request. */
$params = $this->extractRequestParams();
if ( !is_null( $params['tag'] ) ) {
$this->addTables( 'change_tag' );
$this->addJoinConds( [ 'change_tag' => [ 'INNER JOIN', [ 'rc_id=ct_rc_id' ] ] ] );
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
- try {
- $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
- } catch ( NameTableAccessException $exception ) {
- // Return nothing.
- $this->addWhere( '1=0' );
- }
- } else {
- $this->addWhereFld( 'ct_tag', $params['tag'] );
+ $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+ try {
+ $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+ } catch ( NameTableAccessException $exception ) {
+ // Return nothing.
+ $this->addWhere( '1=0' );
}
}
}
protected function run( ApiPageSet $resultPageSet = null ) {
- global $wgActorTableSchemaMigrationStage, $wgChangeTagsSchemaMigrationStage;
+ global $wgActorTableSchemaMigrationStage;
$params = $this->extractRequestParams( false );
$revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
$this->addJoinConds(
[ 'change_tag' => [ 'INNER JOIN', [ 'rev_id=ct_rev_id' ] ] ]
);
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
- try {
- $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
- } catch ( NameTableAccessException $exception ) {
- // Return nothing.
- $this->addWhere( '1=0' );
- }
- } else {
- $this->addWhereFld( 'ct_tag', $params['tag'] );
+ $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+ try {
+ $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+ } catch ( NameTableAccessException $exception ) {
+ // Return nothing.
+ $this->addWhere( '1=0' );
}
}
* @param int $limit
*/
private function prepareQuery( array $users, $limit ) {
- global $wgActorTableSchemaMigrationStage, $wgChangeTagsSchemaMigrationStage;
+ global $wgActorTableSchemaMigrationStage;
$this->resetQueryParams();
$db = $this->getDB();
$this->addJoinConds(
[ 'change_tag' => [ 'INNER JOIN', [ $idField . ' = ct_rev_id' ] ] ]
);
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
- try {
- $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $this->params['tag'] ) );
- } catch ( NameTableAccessException $exception ) {
- // Return nothing.
- $this->addWhere( '1=0' );
- }
- } else {
- $this->addWhereFld( 'ct_tag', $this->params['tag'] );
+ $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+ try {
+ $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $this->params['tag'] ) );
+ } catch ( NameTableAccessException $exception ) {
+ // Return nothing.
+ $this->addWhere( '1=0' );
}
}
}
&$rev_id = null, &$log_id = null, $params = null, RecentChange $rc = null,
User $user = null
) {
- global $wgChangeTagsSchemaMigrationStage;
-
$tagsToAdd = array_filter( (array)$tagsToAdd ); // Make sure we're submitting all tags...
$tagsToRemove = array_filter( (array)$tagsToRemove );
$changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
if ( count( $tagsToAdd ) ) {
$changeTagMapping = [];
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
- foreach ( $tagsToAdd as $tag ) {
- $changeTagMapping[$tag] = $changeTagDefStore->acquireId( $tag );
- }
- // T207881: update the counts at the end of the transaction
- $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tagsToAdd ) {
- $dbw->update(
- 'change_tag_def',
- [ 'ctd_count = ctd_count + 1' ],
- [ 'ctd_name' => $tagsToAdd ],
- __METHOD__
- );
- } );
+ foreach ( $tagsToAdd as $tag ) {
+ $changeTagMapping[$tag] = $changeTagDefStore->acquireId( $tag );
}
+ // T207881: update the counts at the end of the transaction
+ $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tagsToAdd ) {
+ $dbw->update(
+ 'change_tag_def',
+ [ 'ctd_count = ctd_count + 1' ],
+ [ 'ctd_name' => $tagsToAdd ],
+ __METHOD__
+ );
+ } );
$tagsRows = [];
foreach ( $tagsToAdd as $tag ) {
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $tagName = null;
- } else {
- $tagName = $tag;
- }
// Filter so we don't insert NULLs as zero accidentally.
// Keep in mind that $rc_id === null means "I don't care/know about the
// rc_id, just delete $tag on this revision/log entry". It doesn't
// mean "only delete tags on this revision/log WHERE rc_id IS NULL".
$tagsRows[] = array_filter(
[
- 'ct_tag' => $tagName,
'ct_rc_id' => $rc_id,
'ct_log_id' => $log_id,
'ct_rev_id' => $rev_id,
// delete from change_tag
if ( count( $tagsToRemove ) ) {
foreach ( $tagsToRemove as $tag ) {
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $tagName = null;
- $tagId = $changeTagDefStore->getId( $tag );
- } else {
- $tagName = $tag;
- $tagId = null;
- }
$conds = array_filter(
[
- 'ct_tag' => $tagName,
'ct_rc_id' => $rc_id,
'ct_log_id' => $log_id,
'ct_rev_id' => $rev_id,
- 'ct_tag_id' => $tagId,
+ 'ct_tag_id' => $changeTagDefStore->getId( $tag ),
]
);
$dbw->delete( 'change_tag', $conds, __METHOD__ );
- if ( $dbw->affectedRows() && $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
+ if ( $dbw->affectedRows() ) {
// T207881: update the counts at the end of the transaction
$dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tag ) {
$dbw->update(
public static function modifyDisplayQuery( &$tables, &$fields, &$conds,
&$join_conds, &$options, $filter_tag = ''
) {
- global $wgChangeTagsSchemaMigrationStage, $wgUseTagFilter;
+ global $wgUseTagFilter;
// Normalize to arrays
$tables = (array)$tables;
$tables[] = 'change_tag';
$join_conds['change_tag'] = [ 'INNER JOIN', $join_cond ];
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $filterTagIds = [];
- $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
- foreach ( (array)$filter_tag as $filterTagName ) {
- try {
- $filterTagIds[] = $changeTagDefStore->getId( $filterTagName );
- } catch ( NameTableAccessException $exception ) {
- // Return nothing.
- $conds[] = '0';
- break;
- };
- }
+ $filterTagIds = [];
+ $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+ foreach ( (array)$filter_tag as $filterTagName ) {
+ try {
+ $filterTagIds[] = $changeTagDefStore->getId( $filterTagName );
+ } catch ( NameTableAccessException $exception ) {
+ // Return nothing.
+ $conds[] = '0';
+ break;
+ };
+ }
- if ( $filterTagIds !== [] ) {
- $conds['ct_tag_id'] = $filterTagIds;
- }
- } else {
- $conds['ct_tag'] = $filter_tag;
+ if ( $filterTagIds !== [] ) {
+ $conds['ct_tag_id'] = $filterTagIds;
}
if (
* @throws MWException When unable to determine appropriate JOIN condition for tagging
*/
public static function makeTagSummarySubquery( $tables ) {
- global $wgChangeTagsSchemaMigrationStage;
-
// Normalize to arrays
$tables = (array)$tables;
throw new MWException( 'Unable to determine appropriate JOIN condition for tagging.' );
}
- $tagTables[] = 'change_tag';
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $tagTables[] = 'change_tag_def';
- $join_cond_ts_tags = [ 'change_tag_def' => [ 'INNER JOIN', 'ct_tag_id=ctd_id' ] ];
- $field = 'ctd_name';
- } else {
- $field = 'ct_tag';
- $join_cond_ts_tags = [];
- }
+ $tagTables = [ 'change_tag', 'change_tag_def' ];
+ $join_cond_ts_tags = [ 'change_tag_def' => [ 'INNER JOIN', 'ct_tag_id=ctd_id' ] ];
+ $field = 'ctd_name';
return wfGetDB( DB_REPLICA )->buildGroupConcatField(
',', $tagTables, $field, $join_cond, $join_cond_ts_tags
* @since 1.25
*/
public static function defineTag( $tag ) {
- global $wgChangeTagsSchemaMigrationStage;
-
$dbw = wfGetDB( DB_MASTER );
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
- $tagDef = [
- 'ctd_name' => $tag,
- 'ctd_user_defined' => 1,
- 'ctd_count' => 0
- ];
- $dbw->upsert(
- 'change_tag_def',
- $tagDef,
- [ 'ctd_name' ],
- [ 'ctd_user_defined' => 1 ],
- __METHOD__
- );
- }
+ $tagDef = [
+ 'ctd_name' => $tag,
+ 'ctd_user_defined' => 1,
+ 'ctd_count' => 0
+ ];
+ $dbw->upsert(
+ 'change_tag_def',
+ $tagDef,
+ [ 'ctd_name' ],
+ [ 'ctd_user_defined' => 1 ],
+ __METHOD__
+ );
- if ( $wgChangeTagsSchemaMigrationStage < MIGRATION_NEW ) {
- $dbw->replace(
- 'valid_tag',
- [ 'vt_tag' ],
- [ 'vt_tag' => $tag ],
- __METHOD__
- );
- }
// clear the memcache of defined tags
self::purgeTagCacheAll();
}
* @since 1.25
*/
public static function undefineTag( $tag ) {
- global $wgChangeTagsSchemaMigrationStage;
-
$dbw = wfGetDB( DB_MASTER );
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
- $dbw->update(
- 'change_tag_def',
- [ 'ctd_user_defined' => 0 ],
- [ 'ctd_name' => $tag ],
- __METHOD__
- );
-
- $dbw->delete(
- 'change_tag_def',
- [ 'ctd_name' => $tag, 'ctd_count' => 0 ],
- __METHOD__
- );
- }
+ $dbw->update(
+ 'change_tag_def',
+ [ 'ctd_user_defined' => 0 ],
+ [ 'ctd_name' => $tag ],
+ __METHOD__
+ );
- if ( $wgChangeTagsSchemaMigrationStage < MIGRATION_NEW ) {
- $dbw->delete( 'valid_tag', [ 'vt_tag' => $tag ], __METHOD__ );
- }
+ $dbw->delete(
+ 'change_tag_def',
+ [ 'ctd_name' => $tag, 'ctd_count' => 0 ],
+ __METHOD__
+ );
// clear the memcache of defined tags
self::purgeTagCacheAll();
* @since 1.25
*/
public static function deleteTagEverywhere( $tag ) {
- global $wgChangeTagsSchemaMigrationStage;
$dbw = wfGetDB( DB_MASTER );
$dbw->startAtomic( __METHOD__ );
// delete from valid_tag and/or set ctd_user_defined = 0
self::undefineTag( $tag );
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $tagId = MediaWikiServices::getInstance()->getChangeTagDefStore()->getId( $tag );
- $conditions = [ 'ct_tag_id' => $tagId ];
- } else {
- $conditions = [ 'ct_tag' => $tag ];
- }
+ $tagId = MediaWikiServices::getInstance()->getChangeTagDefStore()->getId( $tag );
+ $conditions = [ 'ct_tag_id' => $tagId ];
// find out which revisions use this tag, so we can delete from tag_summary
$result = $dbw->select( 'change_tag',
}
// delete from change_tag
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $tagId = MediaWikiServices::getInstance()->getChangeTagDefStore()->getId( $tag );
- $dbw->delete( 'change_tag', [ 'ct_tag_id' => $tagId ], __METHOD__ );
- } else {
- $dbw->delete( 'change_tag', [ 'ct_tag' => $tag ], __METHOD__ );
- }
-
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
- $dbw->delete( 'change_tag_def', [ 'ctd_name' => $tag ], __METHOD__ );
- }
-
+ $tagId = MediaWikiServices::getInstance()->getChangeTagDefStore()->getId( $tag );
+ $dbw->delete( 'change_tag', [ 'ct_tag_id' => $tagId ], __METHOD__ );
+ $dbw->delete( 'change_tag_def', [ 'ctd_name' => $tag ], __METHOD__ );
$dbw->endAtomic( __METHOD__ );
// give extensions a chance
$cache->makeKey( 'valid-tags-db' ),
WANObjectCache::TTL_MINUTE * 5,
function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
- global $wgChangeTagsSchemaMigrationStage;
$dbr = wfGetDB( DB_REPLICA );
$setOpts += Database::getCacheSetOptions( $dbr );
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- $tags = self::listExplicitlyDefinedTagsNewBackend();
- } else {
- $tags = $dbr->selectFieldValues( 'valid_tag', 'vt_tag', [], $fname );
- }
+ $tags = $dbr->selectFieldValues(
+ 'change_tag_def',
+ 'ctd_name',
+ [ 'ctd_user_defined' => 1 ],
+ __METHOD__
+ );
return array_filter( array_unique( $tags ) );
},
);
}
- /**
- * Lists tags explicitly user defined tags. When ctd_user_defined is true.
- *
- * @return string[] Array of strings: tags
- * @since 1.25
- */
- private static function listExplicitlyDefinedTagsNewBackend() {
- $dbr = wfGetDB( DB_REPLICA );
- return $dbr->selectFieldValues(
- 'change_tag_def',
- 'ctd_name',
- [ 'ctd_user_defined' => 1 ],
- __METHOD__
- );
- }
-
/**
* Lists tags defined by core or extensions using the ListDefinedTags hook.
* Extensions need only define those tags they deem to be in active use.
* Returns a map of any tags used on the wiki to number of edits
* tagged with them, ordered descending by the hitcount.
* This does not include tags defined somewhere that have never been applied.
- *
- * Keeps a short-term cache in memory, so calling this multiple times in the
- * same request should be fine.
- *
* @return array Array of string => int
*/
public static function tagUsageStatistics() {
- global $wgChangeTagsSchemaMigrationStage;
- if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
- return self::newTagUsageStatistics();
- }
-
- $fname = __METHOD__;
- $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
- return $cache->getWithSetCallback(
- $cache->makeKey( 'change-tag-statistics' ),
- WANObjectCache::TTL_MINUTE * 5,
- function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
- $dbr = wfGetDB( DB_REPLICA, 'vslow' );
-
- $setOpts += Database::getCacheSetOptions( $dbr );
-
- $res = $dbr->select(
- 'change_tag',
- [ 'ct_tag', 'hitcount' => 'count(*)' ],
- [],
- $fname,
- [ 'GROUP BY' => 'ct_tag', 'ORDER BY' => 'hitcount DESC' ]
- );
-
- $out = [];
- foreach ( $res as $row ) {
- $out[$row->ct_tag] = $row->hitcount;
- }
-
- return $out;
- },
- [
- 'checkKeys' => [ $cache->makeKey( 'change-tag-statistics' ) ],
- 'lockTSE' => WANObjectCache::TTL_MINUTE * 5,
- 'pcTTL' => WANObjectCache::TTL_PROC_LONG
- ]
- );
- }
-
- /**
- * Same self::tagUsageStatistics() but uses change_tag_def.
- *
- * @return array Array of string => int
- */
- private static function newTagUsageStatistics() {
$dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select(
'change_tag_def',
$this->addOption( 'set-user-tags-only', 'Only update ctd_user_defined from valid_tag table' );
}
- public function execute() {
- global $wgChangeTagsSchemaMigrationStage;
- if ( $wgChangeTagsSchemaMigrationStage === MIGRATION_OLD ) {
- // Return "success", but don't flag it as done so the next run will retry
- $this->output( '... Not run, $wgChangeTagsSchemaMigrationStage === MIGRATION_OLD' . "\n" );
- return true;
- }
- return parent::execute();
- }
-
protected function doDBUpdates() {
$this->lbFactory = MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$this->setBatchSize( $this->getOption( 'batch-size', $this->getBatchSize() ) );
}
public function testBlockWithTag() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- ChangeTags::defineTag( 'custom tag' );
-
- $this->doBlock( [ 'tags' => 'custom tag' ] );
-
- $dbw = wfGetDB( DB_MASTER );
- $this->assertSame( 1, (int)$dbw->selectField(
- [ 'change_tag', 'logging' ],
- 'COUNT(*)',
- [ 'log_type' => 'block', 'ct_tag' => 'custom tag' ],
- __METHOD__,
- [],
- [ 'change_tag' => [ 'INNER JOIN', 'ct_log_id = log_id' ] ]
- ) );
- }
-
- public function testBlockWithTagNewBackend() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
ChangeTags::defineTag( 'custom tag' );
$this->doBlock( [ 'tags' => 'custom tag' ] );
}
public function testDeleteWithTag() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- $name = 'Help:' . ucfirst( __FUNCTION__ );
-
- ChangeTags::defineTag( 'custom tag' );
-
- $this->editPage( $name, 'Some text' );
-
- $this->doApiRequestWithToken( [
- 'action' => 'delete',
- 'title' => $name,
- 'tags' => 'custom tag',
- ] );
-
- $this->assertFalse( Title::newFromText( $name )->exists() );
-
- $dbw = wfGetDB( DB_MASTER );
- $this->assertSame( 'custom tag', $dbw->selectField(
- [ 'change_tag', 'logging' ],
- 'ct_tag',
- [
- 'log_namespace' => NS_HELP,
- 'log_title' => ucfirst( __FUNCTION__ ),
- ],
- __METHOD__,
- [],
- [ 'change_tag' => [ 'INNER JOIN', 'ct_log_id = log_id' ] ]
- ) );
- }
-
- public function testDeleteWithTagNewBackend() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
$name = 'Help:' . ucfirst( __FUNCTION__ );
ChangeTags::defineTag( 'custom tag' );
}
public function testEditWithTag() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- $name = 'Help:' . ucfirst( __FUNCTION__ );
-
- ChangeTags::defineTag( 'custom tag' );
-
- $revId = $this->doApiRequestWithToken( [
- 'action' => 'edit',
- 'title' => $name,
- 'text' => 'Some text',
- 'tags' => 'custom tag',
- ] )[0]['edit']['newrevid'];
-
- $dbw = wfGetDB( DB_MASTER );
- $this->assertSame( 'custom tag', $dbw->selectField(
- 'change_tag', 'ct_tag', [ 'ct_rev_id' => $revId ], __METHOD__ ) );
- }
-
- public function testEditWithTagNewBackend() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
$name = 'Help:' . ucfirst( __FUNCTION__ );
ChangeTags::defineTag( 'custom tag' );
$this->doUnblock( [ 'user' => $this->blocker->getName() ] );
}
- // XXX These three tests copy-pasted from ApiBlockTest.php
- public function testUnblockWithTag() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- ChangeTags::defineTag( 'custom tag' );
-
- $this->doUnblock( [ 'tags' => 'custom tag' ] );
-
- $dbw = wfGetDB( DB_MASTER );
- $this->assertSame( 1, (int)$dbw->selectField(
- [ 'change_tag', 'logging' ],
- 'COUNT(*)',
- [ 'log_type' => 'block', 'ct_tag' => 'custom tag' ],
- __METHOD__,
- [],
- [ 'change_tag' => [ 'INNER JOIN', 'ct_log_id = log_id' ] ]
- ) );
- }
-
public function testUnblockWithTagNewBackend() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
ChangeTags::defineTag( 'custom tag' );
$this->doUnblock( [ 'tags' => 'custom tag' ] );
}
public function testWithTag() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- ChangeTags::defineTag( 'custom tag' );
-
- $user = $this->getMutableTestUser()->getUser();
-
- $this->doSuccessfulRightsChange( 'sysop', [ 'tags' => 'custom tag' ], $user );
-
- $dbr = wfGetDB( DB_REPLICA );
- $this->assertSame(
- 'custom tag',
- $dbr->selectField(
- [ 'change_tag', 'logging' ],
- 'ct_tag',
- [
- 'ct_log_id = log_id',
- 'log_namespace' => NS_USER,
- 'log_title' => strtr( $user->getName(), ' ', '_' )
- ],
- __METHOD__
- )
- );
- }
-
- public function testWithTagNewBackend() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
ChangeTags::defineTag( 'custom tag' );
$user = $this->getMutableTestUser()->getUser();
$this->assertEquals( $expected, $actual );
}
- public function testUpdateTagsMigrationOld() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_OLD );
- $dbw = wfGetDB( DB_MASTER );
- $dbw->delete( 'change_tag', '*' );
- $dbw->delete( 'change_tag_def', '*' );
-
- $rcId = 123;
- ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
-
- $dbr = wfGetDB( DB_REPLICA );
-
- $res = $dbr->select( 'change_tag_def', [ 'ctd_name', 'ctd_id', 'ctd_count' ], '' );
- $this->assertEquals( [], iterator_to_array( $res, false ) );
-
- $expected2 = [
- (object)[
- 'ct_tag' => 'tag1',
- 'ct_tag_id' => null,
- 'ct_rc_id' => 123
- ],
- (object)[
- 'ct_tag' => 'tag2',
- 'ct_tag_id' => null,
- 'ct_rc_id' => 123
- ],
- ];
- $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
- $this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
-
- $rcId = 124;
- ChangeTags::updateTags( [ 'tag1', 'tag3' ], [], $rcId );
-
- $dbr = wfGetDB( DB_REPLICA );
-
- $res = $dbr->select( 'change_tag_def', [ 'ctd_name', 'ctd_id', 'ctd_count' ], '' );
- $this->assertEquals( [], iterator_to_array( $res, false ) );
-
- $expected2 = [
- (object)[
- 'ct_tag' => 'tag1',
- 'ct_tag_id' => null,
- 'ct_rc_id' => 123
- ],
- (object)[
- 'ct_tag' => 'tag2',
- 'ct_tag_id' => null,
- 'ct_rc_id' => 123
- ],
- (object)[
- 'ct_tag' => 'tag1',
- 'ct_tag_id' => null,
- 'ct_rc_id' => 124
- ],
- (object)[
- 'ct_tag' => 'tag3',
- 'ct_tag_id' => null,
- 'ct_rc_id' => 124
- ],
- ];
- $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
- $this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
- }
-
- public function testUpdateTagsMigrationWriteBoth() {
+ public function testUpdateTags() {
// FIXME: fails under postgres
$this->markTestSkippedIfDbType( 'postgres' );
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
$dbw = wfGetDB( DB_MASTER );
$dbw->delete( 'change_tag', '*' );
$dbw->delete( 'change_tag_def', '*' );
$expected2 = [
(object)[
- 'ct_tag' => 'tag1',
'ct_tag_id' => 1,
'ct_rc_id' => 123
],
(object)[
- 'ct_tag' => 'tag2',
'ct_tag_id' => 2,
'ct_rc_id' => 123
],
];
- $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
+ $res2 = $dbr->select( 'change_tag', [ 'ct_tag_id', 'ct_rc_id' ], '' );
$this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
$rcId = 124;
$expected2 = [
(object)[
- 'ct_tag' => 'tag1',
'ct_tag_id' => 1,
'ct_rc_id' => 123
],
(object)[
- 'ct_tag' => 'tag2',
'ct_tag_id' => 2,
'ct_rc_id' => 123
],
(object)[
- 'ct_tag' => 'tag1',
'ct_tag_id' => 1,
'ct_rc_id' => 124
],
(object)[
- 'ct_tag' => 'tag3',
'ct_tag_id' => 3,
'ct_rc_id' => 124
],
];
- $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
- $this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
- }
-
- public function testDeleteTagsMigrationOld() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_OLD );
- $dbw = wfGetDB( DB_MASTER );
- $dbw->delete( 'change_tag', '*' );
- $dbw->delete( 'change_tag_def', '*' );
-
- $rcId = 123;
- ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
-
- ChangeTags::updateTags( [], [ 'tag2' ], $rcId );
-
- $dbr = wfGetDB( DB_REPLICA );
-
- $res = $dbr->select( 'change_tag_def', [ 'ctd_name', 'ctd_id', 'ctd_count' ], '' );
- $this->assertEquals( [], iterator_to_array( $res, false ) );
-
- $expected2 = [
- (object)[
- 'ct_tag' => 'tag1',
- 'ct_tag_id' => null,
- 'ct_rc_id' => 123
- ]
- ];
- $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
+ $res2 = $dbr->select( 'change_tag', [ 'ct_tag_id', 'ct_rc_id' ], '' );
$this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
}
- public function testDeleteTagsMigrationWriteBoth() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
+ public function testDeleteTags() {
$dbw = wfGetDB( DB_MASTER );
$dbw->delete( 'change_tag', '*' );
$dbw->delete( 'change_tag_def', '*' );
$expected2 = [
(object)[
- 'ct_tag' => 'tag1',
'ct_tag_id' => 1,
'ct_rc_id' => 123
]
];
- $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
+ $res2 = $dbr->select( 'change_tag', [ 'ct_tag_id', 'ct_rc_id' ], '' );
$this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
}
- public function testTagUsageStatisticsOldBackend() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_OLD );
- $this->setMwGlobals( 'wgTagStatisticsNewTable', false );
-
- $dbw = wfGetDB( DB_MASTER );
- $dbw->delete( 'change_tag', '*' );
- $dbw->delete( 'change_tag_def', '*' );
-
- $rcId = 123;
- ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
-
- $rcId = 124;
- ChangeTags::updateTags( [ 'tag1' ], [], $rcId );
-
- $this->assertEquals( [ 'tag1' => 2, 'tag2' => 1 ], ChangeTags::tagUsageStatistics() );
- }
-
- public function testTagUsageStatisticsNewMigrationOldBackedn() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- $this->setMwGlobals( 'wgTagStatisticsNewTable', false );
-
- $dbw = wfGetDB( DB_MASTER );
- $dbw->delete( 'change_tag', '*' );
- $dbw->delete( 'change_tag_def', '*' );
- MediaWikiServices::getInstance()->resetServiceForTesting( 'NameTableStoreFactory' );
-
- $rcId = 123;
- ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
-
- $rcId = 124;
- ChangeTags::updateTags( [ 'tag1' ], [], $rcId );
-
- $this->assertEquals( [ 'tag1' => 2, 'tag2' => 1 ], ChangeTags::tagUsageStatistics() );
- }
-
- public function testTagUsageStatisticsNewBackend() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- $this->setMwGlobals( 'wgTagStatisticsNewTable', true );
-
+ public function testTagUsageStatistics() {
$dbw = wfGetDB( DB_MASTER );
$dbw->delete( 'change_tag', '*' );
$dbw->delete( 'change_tag_def', '*' );
$this->assertEquals( [ 'tag1' => 2, 'tag2' => 1 ], ChangeTags::tagUsageStatistics() );
}
- public function testListExplicitlyDefinedTagsOld() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_OLD );
- $dbw = wfGetDB( DB_MASTER );
- $dbw->delete( 'change_tag', '*' );
- $dbw->delete( 'change_tag_def', '*' );
- $dbw->delete( 'valid_tag', '*' );
-
- $rcId = 123;
- ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
- ChangeTags::defineTag( 'tag2' );
-
- $this->assertEquals( [ 'tag2' ], ChangeTags::listExplicitlyDefinedTags() );
- $dbr = wfGetDB( DB_REPLICA );
- $res = $dbr->select( 'change_tag_def', [ 'ctd_name', 'ctd_user_defined' ], '' );
- $this->assertEquals( [], iterator_to_array( $res, false ) );
-
- $this->assertEquals( [ 'tag2' ], $dbr->selectFieldValues( 'valid_tag', 'vt_tag', '' ) );
- }
-
- public function testListExplicitlyDefinedTagsWriteBoth() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- $dbw = wfGetDB( DB_MASTER );
- $dbw->delete( 'change_tag', '*' );
- $dbw->delete( 'change_tag_def', '*' );
- $dbw->delete( 'valid_tag', '*' );
-
- $rcId = 123;
- ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
- ChangeTags::defineTag( 'tag2' );
-
- $this->assertEquals( [ 'tag2' ], ChangeTags::listExplicitlyDefinedTags() );
- $dbr = wfGetDB( DB_REPLICA );
-
- $expected = [
- (object)[
- 'ctd_name' => 'tag1',
- 'ctd_user_defined' => 0
- ],
- (object)[
- 'ctd_name' => 'tag2',
- 'ctd_user_defined' => 1
- ],
- ];
- $res = $dbr->select( 'change_tag_def', [ 'ctd_name', 'ctd_user_defined' ], '' );
- $this->assertEquals( $expected, iterator_to_array( $res, false ) );
-
- $this->assertEquals( [ 'tag2' ], $dbr->selectFieldValues( 'valid_tag', 'vt_tag', '' ) );
- }
-
- public function testListExplicitlyDefinedTagsNew() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
+ public function testListExplicitlyDefinedTags() {
$dbw = wfGetDB( DB_MASTER );
$dbw->delete( 'change_tag', '*' );
$dbw->delete( 'change_tag_def', '*' );
+++ /dev/null
-<?php
-
-namespace MediaWiki\Tests\Maintenance;
-
-use PopulateChangeTagDef;
-
-/**
- * @group Database
- * @covers PopulateChangeTagDef
- */
-class PopulateChangeTagDefTest extends MaintenanceBaseTestCase {
-
- public function getMaintenanceClass() {
- return PopulateChangeTagDef::class;
- }
-
- public function setUp() {
- parent::setUp();
- $this->tablesUsed = [ 'change_tag', 'change_tag_def', 'updatelog' ];
-
- $this->cleanChangeTagTables();
- $this->insertChangeTagData();
- }
-
- private function cleanChangeTagTables() {
- wfGetDB( DB_MASTER )->delete( 'change_tag', '*' );
- wfGetDB( DB_MASTER )->delete( 'change_tag_def', '*' );
- wfGetDB( DB_MASTER )->delete( 'updatelog', '*' );
- }
-
- private function insertChangeTagData() {
- $changeTags = [];
-
- $changeTags[] = [
- 'ct_rc_id' => 1234,
- 'ct_tag' => 'One Tag',
- ];
-
- $changeTags[] = [
- 'ct_rc_id' => 1235,
- 'ct_tag' => 'Two Tags',
- ];
-
- $changeTags[] = [
- 'ct_log_id' => 1236,
- 'ct_tag' => 'Two Tags',
- ];
-
- $changeTags[] = [
- 'ct_rev_id' => 1237,
- 'ct_tag' => 'Three Tags',
- ];
-
- $changeTags[] = [
- 'ct_rc_id' => 1238,
- 'ct_tag' => 'Three Tags',
- ];
-
- $changeTags[] = [
- 'ct_log_id' => 1239,
- 'ct_tag' => 'Three Tags',
- ];
-
- wfGetDB( DB_MASTER )->insert( 'change_tag', $changeTags );
- }
-
- public function testRun() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- $this->maintenance->loadWithArgv( [ '--sleep', '0' ] );
-
- $this->maintenance->execute();
-
- $changeTagDefRows = [
- (object)[
- 'ctd_name' => 'One Tag',
- 'ctd_count' => 1,
- ],
- (object)[
- 'ctd_name' => 'Two Tags',
- 'ctd_count' => 2,
- ],
- (object)[
- 'ctd_name' => 'Three Tags',
- 'ctd_count' => 3,
- ],
- ];
-
- $actualChangeTagDefs = wfGetDB( DB_REPLICA )->select(
- [ 'change_tag_def' ],
- [ 'ctd_name', 'ctd_count' ],
- [],
- __METHOD__,
- [ 'ORDER BY' => 'ctd_count' ]
- );
-
- $this->assertEquals( $changeTagDefRows, iterator_to_array( $actualChangeTagDefs, false ) );
-
- // Check if change_tag is also backpopulated
- $actualChangeTags = wfGetDB( DB_REPLICA )->select(
- [ 'change_tag', 'change_tag_def' ],
- [ 'ct_tag', 'ct_tag_id', 'ctd_count' ],
- [],
- __METHOD__,
- [],
- [ 'change_tag_def' => [ 'LEFT JOIN', 'ct_tag_id=ctd_id' ] ]
- );
- $mapping = [
- 'One Tag' => 1,
- 'Two Tags' => 2,
- 'Three Tags' => 3
- ];
- foreach ( $actualChangeTags as $row ) {
- $this->assertNotNull( $row->ct_tag_id );
- $this->assertEquals( $row->ctd_count, $mapping[$row->ct_tag] );
- }
- }
-
- public function testRunUpdateHitCountMigrationNew() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
- $changeTagDefBadRows = [
- [
- 'ctd_name' => 'One Tag',
- 'ctd_user_defined' => 0,
- 'ctd_count' => 50,
- ],
- [
- 'ctd_name' => 'Two Tags',
- 'ctd_user_defined' => 0,
- 'ctd_count' => 4,
- ],
- [
- 'ctd_name' => 'Three Tags',
- 'ctd_user_defined' => 0,
- 'ctd_count' => 3,
- ],
- ];
- wfGetDB( DB_MASTER )->insert(
- 'change_tag_def',
- $changeTagDefBadRows
- );
-
- $mapping = [
- 'One Tag' => 1,
- 'Two Tags' => 2,
- 'Three Tags' => 3
- ];
- foreach ( $mapping as $tagName => $tagId ) {
- wfGetDB( DB_MASTER )->update(
- 'change_tag',
- [ 'ct_tag_id' => $tagId ],
- [ 'ct_tag' => $tagName ]
- );
- }
-
- $this->maintenance->loadWithArgv( [ '--sleep', '0' ] );
-
- $this->maintenance->execute();
-
- $changeTagDefRows = [
- (object)[
- 'ctd_name' => 'One Tag',
- 'ctd_count' => 1,
- ],
- (object)[
- 'ctd_name' => 'Two Tags',
- 'ctd_count' => 2,
- ],
- (object)[
- 'ctd_name' => 'Three Tags',
- 'ctd_count' => 3,
- ],
- ];
-
- $actualChangeTagDefs = wfGetDB( DB_REPLICA )->select(
- [ 'change_tag_def' ],
- [ 'ctd_name', 'ctd_count' ],
- [],
- __METHOD__,
- [ 'ORDER BY' => 'ctd_count' ]
- );
-
- $this->assertEquals( $changeTagDefRows, iterator_to_array( $actualChangeTagDefs, false ) );
- }
-
- public function testRunUpdateHitCountMigrationWriteBoth() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- $changeTagDefBadRows = [
- [
- 'ctd_name' => 'One Tag',
- 'ctd_user_defined' => 0,
- 'ctd_count' => 50,
- ],
- [
- 'ctd_name' => 'Two Tags',
- 'ctd_user_defined' => 0,
- 'ctd_count' => 4,
- ],
- [
- 'ctd_name' => 'Three Tags',
- 'ctd_user_defined' => 0,
- 'ctd_count' => 3,
- ],
- ];
- wfGetDB( DB_MASTER )->insert(
- 'change_tag_def',
- $changeTagDefBadRows
- );
-
- $this->maintenance->loadWithArgv( [ '--sleep', '0' ] );
-
- $this->maintenance->execute();
-
- $changeTagDefRows = [
- (object)[
- 'ctd_name' => 'One Tag',
- 'ctd_count' => 1,
- ],
- (object)[
- 'ctd_name' => 'Two Tags',
- 'ctd_count' => 2,
- ],
- (object)[
- 'ctd_name' => 'Three Tags',
- 'ctd_count' => 3,
- ],
- ];
-
- $actualChangeTagDefs = wfGetDB( DB_REPLICA )->select(
- [ 'change_tag_def' ],
- [ 'ctd_name', 'ctd_count' ],
- [],
- __METHOD__,
- [ 'ORDER BY' => 'ctd_count' ]
- );
-
- $this->assertEquals( $changeTagDefRows, iterator_to_array( $actualChangeTagDefs, false ) );
- }
-
- public function testDryRunMigrationNew() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
- $this->maintenance->loadWithArgv( [ '--dry-run', '--sleep', '0' ] );
-
- $this->maintenance->execute();
-
- $actualChangeTagDefs = wfGetDB( DB_REPLICA )->select(
- [ 'change_tag_def' ],
- [ 'ctd_id', 'ctd_name' ]
- );
-
- $this->assertEquals( [], iterator_to_array( $actualChangeTagDefs, false ) );
-
- $actualChangeTags = wfGetDB( DB_REPLICA )->select(
- [ 'change_tag' ],
- [ 'ct_tag_id', 'ct_tag' ]
- );
-
- foreach ( $actualChangeTags as $row ) {
- $this->assertNull( $row->ct_tag_id );
- $this->assertNotNull( $row->ct_tag );
- }
- }
-
- public function testDryRunMigrationWriteBoth() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- $this->maintenance->loadWithArgv( [ '--dry-run', '--sleep', '0' ] );
-
- $this->maintenance->execute();
-
- $actualChangeTagDefs = wfGetDB( DB_REPLICA )->select(
- [ 'change_tag_def' ],
- [ 'ctd_id', 'ctd_name' ]
- );
-
- $this->assertEquals( [], iterator_to_array( $actualChangeTagDefs, false ) );
-
- $actualChangeTags = wfGetDB( DB_REPLICA )->select(
- [ 'change_tag' ],
- [ 'ct_tag_id', 'ct_tag' ]
- );
-
- foreach ( $actualChangeTags as $row ) {
- $this->assertNull( $row->ct_tag_id );
- $this->assertNotNull( $row->ct_tag );
- }
- }
-
-}