Since MediaWiki 1.39 (I66b2cb8653), the actor migration stage is always SCHEMA_COMPAT_NEW, so ActorMigration doesn't really do anything useful and can be replaced with a hard-coded query. This patch marks the class as deprecated and adds information on how to replace it, with the intent of getting backported to 1.39. See https://www.mediawiki.org/wiki/Actor_migration for background. Note that this process happened in MediaWiki 1.34 for wikis using update.php, but the migration code has been kept around so far because the migration process took a long time for some large wikis. Usage check for upcoming hard deprecation: https://codesearch.wmcloud.org/search/?q=%5CbActorMigration%5Cb&i=nope&files=&excludeFiles=&repos= - getWhere('rev_user'), getJoin('rev_user'): used in many extensions and some core classes - getJoin('rc_user'): in SocialProfile, already hard-deprecated - getJoin('log_comment'), getJoin('log_user'): used in ArticleFeedbackv5, already hard-deprecated - getInsertValues('log_user'): used in ArticleFeedbackv5, already hard-deprecated - MIGRATION_STAGE_SCHEMA_COMPAT, class existence check: used in UserMerge, DynamicPageList, UniversalLanguageSelector, StubUserWikiAuth. Might be used for B/C with old MediaWiki versions, there isn't really a proper deprecation path for this use case, but it's only relevant for 1.33 and older, so probably can be let go now. Bug: T227047 Change-Id: Ib02e38d20c5a1f96e68a4f67bbd981375c2e97db
143 lines
3.7 KiB
PHP
143 lines
3.7 KiB
PHP
<?php
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
use MediaWiki\User\ActorStoreFactory;
|
|
use MediaWiki\User\UserIdentity;
|
|
use Wikimedia\Rdbms\IDatabase;
|
|
|
|
/**
|
|
* This is not intended to be a long-term part of MediaWiki; it will be
|
|
* deprecated and removed once actor migration is complete.
|
|
*
|
|
* @since 1.31
|
|
* @since 1.34 Use with 'ar_user', 'img_user', 'oi_user', 'fa_user',
|
|
* 'rc_user', 'log_user', and 'ipb_by' is deprecated. Callers should
|
|
* reference the corresponding actor fields directly.
|
|
* @deprecated since 1.39
|
|
*/
|
|
class ActorMigration extends ActorMigrationBase {
|
|
/**
|
|
* Constant for extensions to feature-test whether $wgActorTableSchemaMigrationStage
|
|
* (in MW <1.34) expects MIGRATION_* or SCHEMA_COMPAT_*
|
|
*/
|
|
public const MIGRATION_STAGE_SCHEMA_COMPAT = 1;
|
|
|
|
/**
|
|
* Field information
|
|
* @see ActorMigrationBase::getFieldInfo()
|
|
*/
|
|
public const FIELD_INFOS = [
|
|
// Deprecated since 1.39
|
|
'rev_user' => [
|
|
'tempTable' => [
|
|
'table' => 'revision_actor_temp',
|
|
'pk' => 'revactor_rev',
|
|
'field' => 'revactor_actor',
|
|
'joinPK' => 'rev_id',
|
|
'extra' => [
|
|
'revactor_timestamp' => 'rev_timestamp',
|
|
'revactor_page' => 'rev_page',
|
|
],
|
|
]
|
|
],
|
|
|
|
// Deprecated since 1.34
|
|
'ar_user' => [
|
|
'deprecatedVersion' => '1.37',
|
|
],
|
|
// Deprecated since 1.34
|
|
'img_user' => [
|
|
'deprecatedVersion' => '1.37',
|
|
],
|
|
// Deprecated since 1.34
|
|
'oi_user' => [
|
|
'deprecatedVersion' => '1.37',
|
|
],
|
|
// Deprecated since 1.34
|
|
'fa_user' => [
|
|
'deprecatedVersion' => '1.37',
|
|
],
|
|
// Deprecated since 1.34
|
|
'rc_user' => [
|
|
'deprecatedVersion' => '1.37',
|
|
],
|
|
// Deprecated since 1.34
|
|
'log_user' => [
|
|
'deprecatedVersion' => '1.37',
|
|
],
|
|
// Deprecated since 1.34
|
|
'ipb_by' => [
|
|
'deprecatedVersion' => '1.37',
|
|
'textField' => 'ipb_by_text',
|
|
'actorField' => 'ipb_by_actor'
|
|
]
|
|
];
|
|
|
|
/**
|
|
* Static constructor
|
|
* @return self
|
|
*/
|
|
public static function newMigration() {
|
|
return MediaWikiServices::getInstance()->getActorMigration();
|
|
}
|
|
|
|
/**
|
|
* @internal
|
|
*
|
|
* @param int $stage
|
|
* @param ActorStoreFactory $actorStoreFactory
|
|
*/
|
|
public function __construct(
|
|
$stage,
|
|
ActorStoreFactory $actorStoreFactory
|
|
) {
|
|
if ( $stage & SCHEMA_COMPAT_OLD ) {
|
|
throw new InvalidArgumentException(
|
|
'The old actor table schema is no longer supported' );
|
|
}
|
|
parent::__construct(
|
|
self::FIELD_INFOS,
|
|
$stage,
|
|
$actorStoreFactory
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
* @deprecated since 1.39 Use `{table} JOIN actor ON {table_prefix}_actor = actor_id`
|
|
* E.g. for key=rev_user, use `revision JOIN actor ON rev_actor = actor_id`
|
|
*/
|
|
public function getJoin( $key ) {
|
|
return parent::getJoin( $key );
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
* @deprecated since 1.39 Use `{table_prefix}_actor IN ({list of actor IDs})`.
|
|
* E.g. for key=rev_user, use `rev_actor IN ({list of actor IDs})`.
|
|
* Use `MediaWikiServices::getInstance()->getActorNormalization()
|
|
* ->findActorId( $user, $db )` to get the actor ID for a given user.
|
|
*/
|
|
public function getWhere( IDatabase $db, $key, $users, $useId = true ) {
|
|
return parent::getWhere( $db, $key, $users, $useId );
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
* @deprecated since 1.39 Use `[ '{table_prefix}_actor' => MediaWikiServices::getInstance()
|
|
* ->getActorNormalization()->acquireActorId( $user, $dbw ) ]`
|
|
* E.g. for key=log_user, use `[ 'log_actor' => ... ]`
|
|
*/
|
|
public function getInsertValues( IDatabase $dbw, $key, UserIdentity $user ) {
|
|
return parent::getInsertValues( $dbw, $key, $user );
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
* @deprecated since 1.39 Use same replacement as getInsertValues().
|
|
*/
|
|
public function getInsertValuesWithTempTable( IDatabase $dbw, $key, UserIdentity $user ) {
|
|
return parent::getInsertValuesWithTempTable( $dbw, $key, $user );
|
|
}
|
|
|
|
}
|