MediaWiki master
MediaWiki\User\ActorMigrationBase Class Reference

This abstract base class helps migrate core and extension code to use the actor table. More...

Inherited by MediaWiki\User\ActorMigration.

Collaboration diagram for MediaWiki\User\ActorMigrationBase:

Public Member Functions

 __construct ( $fieldInfos, $stage, ActorStoreFactory $actorStoreFactory, $options=[])
 
 getInsertValues (IDatabase $dbw, $key, UserIdentity $user)
 Get UPDATE fields for the actor.
 
 getJoin ( $key)
 Get SELECT fields and joins for the actor key.
 
 getWhere (IReadableDatabase $db, $key, $users, $useId=true)
 Get WHERE condition for the actor.
 
 isAnon ( $field)
 Return an SQL condition to test if a user field is anonymous.
 
 isNotAnon ( $field)
 Return an SQL condition to test if a user field is non-anonymous.
 
 setForImport (bool $forImport)
 

Static Public Member Functions

static newMigrationForImport ()
 Get an instance that allows IP actor creation.
 

Protected Member Functions

 checkDeprecation ( $key)
 Issue deprecation warning/error as appropriate.
 
 getActorNormalization ( $domainId)
 
 getFieldInfo ( $key)
 Get config information about a field.
 
 getInstanceName ()
 Get a name for this instance to use in error messages.
 

Protected Attributes

ActorStoreFactory $actorStoreFactory
 

Detailed Description

This abstract base class helps migrate core and extension code to use the actor table.

Stability: stable
to extend
Since
1.37

Definition at line 39 of file ActorMigrationBase.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\ActorMigrationBase::__construct ( $fieldInfos,
$stage,
ActorStoreFactory $actorStoreFactory,
$options = [] )
Parameters
array$fieldInfosAn array of associative arrays, giving configuration information about fields which are being migrated. Subkeys are:
  • removedVersion: The version in which the field was removed
  • deprecatedVersion: The version in which the field was deprecated
  • component: The component for removedVersion and deprecatedVersion. Default: MediaWiki.
  • textField: Override the old text field name. Default {$key}_text.
  • actorField: Override the actor field name. Default {$key}_actor. All subkeys are optional.
Stability: stable
to override
Stability: stable
to call
Parameters
int$stageThe migration stage. This is a combination of SCHEMA_COMPAT_* flags:
  • SCHEMA_COMPAT_READ_OLD, SCHEMA_COMPAT_WRITE_OLD: Use the old schema, with *_user and *_user_text fields.
  • SCHEMA_COMPAT_READ_NEW, SCHEMA_COMPAT_WRITE_NEW: Use the new schema. All relevant tables join directly to the actor table.
ActorStoreFactory$actorStoreFactory
array$optionsArray of other options. May contain:
  • allowUnknown: Allow fields not present in $fieldInfos. True by default.

Definition at line 83 of file ActorMigrationBase.php.

References MediaWiki\User\ActorMigrationBase\$actorStoreFactory, SCHEMA_COMPAT_READ_MASK, SCHEMA_COMPAT_READ_NEW, SCHEMA_COMPAT_READ_OLD, SCHEMA_COMPAT_WRITE_MASK, SCHEMA_COMPAT_WRITE_NEW, and SCHEMA_COMPAT_WRITE_OLD.

Member Function Documentation

◆ checkDeprecation()

MediaWiki\User\ActorMigrationBase::checkDeprecation ( $key)
protected

Issue deprecation warning/error as appropriate.

Access: internal
Parameters
string$key

Definition at line 165 of file ActorMigrationBase.php.

References MediaWiki\User\ActorMigrationBase\getFieldInfo(), and wfDeprecated().

Referenced by MediaWiki\User\ActorMigrationBase\getInsertValues(), MediaWiki\User\ActorMigrationBase\getJoin(), and MediaWiki\User\ActorMigrationBase\getWhere().

◆ getActorNormalization()

MediaWiki\User\ActorMigrationBase::getActorNormalization ( $domainId)
protected
Parameters
string$domainId
Returns
ActorNormalization

Definition at line 380 of file ActorMigrationBase.php.

Referenced by MediaWiki\User\ActorMigrationBase\getInsertValues(), and MediaWiki\User\ActorMigrationBase\getWhere().

◆ getFieldInfo()

MediaWiki\User\ActorMigrationBase::getFieldInfo ( $key)
protected

Get config information about a field.

Stability: stable
to override
Parameters
string$key
Returns
array

Definition at line 131 of file ActorMigrationBase.php.

References MediaWiki\User\ActorMigrationBase\getInstanceName().

Referenced by MediaWiki\User\ActorMigrationBase\checkDeprecation().

◆ getInsertValues()

MediaWiki\User\ActorMigrationBase::getInsertValues ( IDatabase $dbw,
$key,
UserIdentity $user )

Get UPDATE fields for the actor.

Parameters
IDatabase$dbwDatabase to use for creating an actor ID, if necessary
string$keyA key such as "rev_user" identifying the actor field being fetched.
UserIdentity$userUser to set in the update
Returns
array to merge into $values to IDatabase->update() or $a to IDatabase->insert()

Reimplemented in MediaWiki\User\ActorMigration.

Definition at line 266 of file ActorMigrationBase.php.

References MediaWiki\User\ActorMigrationBase\checkDeprecation(), MediaWiki\User\ActorMigrationBase\getActorNormalization(), Wikimedia\Rdbms\IReadableDatabase\getDomainID(), MediaWiki\User\UserIdentity\getId(), MediaWiki\User\UserIdentity\getName(), SCHEMA_COMPAT_WRITE_NEW, and SCHEMA_COMPAT_WRITE_OLD.

◆ getInstanceName()

MediaWiki\User\ActorMigrationBase::getInstanceName ( )
protected

Get a name for this instance to use in error messages.

Stability: stable
to override
Returns
string
Exceptions

\ReflectionException

Definition at line 149 of file ActorMigrationBase.php.

Referenced by MediaWiki\User\ActorMigrationBase\getFieldInfo().

◆ getJoin()

MediaWiki\User\ActorMigrationBase::getJoin ( $key)

Get SELECT fields and joins for the actor key.

Parameters
string$keyA key such as "rev_user" identifying the actor field being fetched.
Returns
array[] With three keys:
  • tables: (string[]) to include in the $table to IDatabase->select() or SelectQueryBuilder::tables
  • fields: (string[]) to include in the $vars to IDatabase->select() or SelectQueryBuilder::fields
  • joins: (array) to include in the $join_conds to IDatabase->select() or SelectQueryBuilder::joinConds All tables, fields, and joins are aliased, so + is safe to use.

Reimplemented in MediaWiki\User\ActorMigration.

Definition at line 223 of file ActorMigrationBase.php.

References MediaWiki\User\ActorMigrationBase\checkDeprecation(), and SCHEMA_COMPAT_READ_OLD.

◆ getWhere()

MediaWiki\User\ActorMigrationBase::getWhere ( IReadableDatabase $db,
$key,
$users,
$useId = true )

Get WHERE condition for the actor.

Parameters
IReadableDatabase$dbDatabase to use for quoting and list-making
string$keyA key such as "rev_user" identifying the actor field being fetched.
UserIdentity | UserIdentity[] | null | false$usersUsers to test for. Passing null, false, or the empty array will return 'conds' that never match, and an empty array for 'orconds'.
bool$useIdIf false, don't try to query by the user ID. Intended for use with rc_user since it has an index on (rc_user_text,rc_timestamp) but not (rc_user,rc_timestamp).
Returns
array With four keys:
  • tables: (string[]) to include in the $table to IDatabase->select() or SelectQueryBuilder::tables
  • conds: (string) to include in the $cond to IDatabase->select() or SelectQueryBuilder::conds
  • orconds: (array[]) array of alternatives in case a union of multiple queries would be more efficient than a query with OR. May have keys 'actor', 'userid', 'username'. Since 1.32, this is guaranteed to contain just one alternative if $users contains a single user.
  • joins: (array) to include in the $join_conds to IDatabase->select() or SelectQueryBuilder::joinConds All tables and joins are aliased, so + is safe to use.

Reimplemented in MediaWiki\User\ActorMigration.

Definition at line 306 of file ActorMigrationBase.php.

References MediaWiki\User\ActorMigrationBase\checkDeprecation(), MediaWiki\User\ActorMigrationBase\getActorNormalization(), Wikimedia\Rdbms\IReadableDatabase\getDomainID(), Wikimedia\Rdbms\Platform\ISQLPlatform\makeList(), and SCHEMA_COMPAT_READ_NEW.

◆ isAnon()

MediaWiki\User\ActorMigrationBase::isAnon ( $field)

Return an SQL condition to test if a user field is anonymous.

Parameters
string$fieldField name or SQL fragment
Returns
string

Definition at line 186 of file ActorMigrationBase.php.

References SCHEMA_COMPAT_READ_NEW.

◆ isNotAnon()

MediaWiki\User\ActorMigrationBase::isNotAnon ( $field)

Return an SQL condition to test if a user field is non-anonymous.

Parameters
string$fieldField name or SQL fragment
Returns
string

Definition at line 195 of file ActorMigrationBase.php.

References SCHEMA_COMPAT_READ_NEW.

◆ newMigrationForImport()

static MediaWiki\User\ActorMigrationBase::newMigrationForImport ( )
static

Get an instance that allows IP actor creation.

Returns
self

Reimplemented in MediaWiki\User\ActorMigration.

Definition at line 119 of file ActorMigrationBase.php.

◆ setForImport()

MediaWiki\User\ActorMigrationBase::setForImport ( bool $forImport)
Access: internal
For use immediately after construction only
Parameters
bool$forImport

Definition at line 372 of file ActorMigrationBase.php.

Member Data Documentation

◆ $actorStoreFactory

ActorStoreFactory MediaWiki\User\ActorMigrationBase::$actorStoreFactory
protected

The documentation for this class was generated from the following file: