MediaWiki REL1_34
ActorMigration Class Reference

This class handles the logic for the actor table migration. More...

Public Member Functions

 __construct ( $stage)
 
 getExistingActorId (IDatabase $db, UserIdentity $user)
 Get actor ID from UserIdentity, if it exists.
 
 getInsertValues (IDatabase $dbw, $key, UserIdentity $user)
 Get UPDATE fields for the actor.
 
 getInsertValuesWithTempTable (IDatabase $dbw, $key, UserIdentity $user)
 Get UPDATE fields for the actor.
 
 getJoin ( $key)
 Get SELECT fields and joins for the actor key.
 
 getNewActorId (IDatabase $dbw, UserIdentity $user)
 Attempt to assign an actor ID to the given user.
 
 getWhere (IDatabase $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.
 

Static Public Member Functions

static newMigration ()
 Static constructor.
 

Public Attributes

const MIGRATION_STAGE_SCHEMA_COMPAT = 1
 Constant for extensions to feature-test whether $wgActorTableSchemaMigrationStage (in MW <1.34) expects MIGRATION_* or SCHEMA_COMPAT_*.
 

Static Private Member Functions

static checkDeprecation ( $key)
 Issue deprecation warning/error as appropriate.
 
static getFieldNames ( $key)
 

Private Attributes

array null $joinCache = null
 Cache for self::getJoin()
 
int $stage
 Combination of SCHEMA_COMPAT_* constants.
 

Static Private Attributes

static string null[] $deprecated
 Define fields that are deprecated for use with this class.
 
static array $formerTempTables = []
 Fields that formerly used $tempTables Key is '$key', value is the MediaWiki version in which it was removed from $tempTables.
 
static string[] $removed = []
 Define fields that are removed for use with this class.
 
static array $specialFields
 Define fields that use non-standard mapping Keys are the user id column name, values are arrays with two elements (the user text column name and the actor id column name)
 
static array $tempTables
 Define fields that use temporary tables for transitional purposes Keys are '$key', values are arrays with four fields:
 

Detailed Description

This class handles the logic for the actor table migration.

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
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.

Definition at line 38 of file ActorMigration.php.

Constructor & Destructor Documentation

◆ __construct()

ActorMigration::__construct (   $stage)

Member Function Documentation

◆ checkDeprecation()

static ActorMigration::checkDeprecation (   $key)
staticprivate

Issue deprecation warning/error as appropriate.

Parameters
string$key

Definition at line 144 of file ActorMigration.php.

References wfDeprecated().

◆ getExistingActorId()

ActorMigration::getExistingActorId ( IDatabase  $db,
UserIdentity  $user 
)

Get actor ID from UserIdentity, if it exists.

Since
1.34.3
Parameters
IDatabase$db
UserIdentity$user
Returns
int|false

Definition at line 247 of file ActorMigration.php.

References MediaWiki\User\UserIdentity\getName(), and Wikimedia\Rdbms\IDatabase\selectRow().

Referenced by getInsertValues().

◆ getFieldNames()

static ActorMigration::getFieldNames (   $key)
staticprivate
Parameters
string$keyA key such as "rev_user" identifying the actor field being fetched.
Returns
string[] [ $text, $actor ]

Definition at line 178 of file ActorMigration.php.

◆ getInsertValues()

ActorMigration::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()

Definition at line 324 of file ActorMigration.php.

References getExistingActorId(), MediaWiki\User\UserIdentity\getId(), MediaWiki\User\UserIdentity\getName(), getNewActorId(), SCHEMA_COMPAT_WRITE_NEW, and SCHEMA_COMPAT_WRITE_OLD.

◆ getInsertValuesWithTempTable()

ActorMigration::getInsertValuesWithTempTable ( 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 with two values:
  • array to merge into $values to IDatabase->update() or $a to IDatabase->insert()
  • callback to call with the primary key for the main table insert and extra fields needed for the temp table.

Definition at line 362 of file ActorMigration.php.

References $t, MediaWiki\User\UserIdentity\getActorId(), MediaWiki\User\UserIdentity\getId(), MediaWiki\User\UserIdentity\getName(), User\newFromAnyId(), SCHEMA_COMPAT_WRITE_NEW, SCHEMA_COMPAT_WRITE_OLD, Wikimedia\Rdbms\IDatabase\upsert(), and wfDeprecated().

◆ getJoin()

ActorMigration::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()
  • fields: (string[]) to include in the $vars to IDatabase->select()
  • joins: (array) to include in the $join_conds to IDatabase->select() All tables, fields, and joins are aliased, so + is safe to use. -return array{tables:string[],fields:string[],joins:array}

Definition at line 194 of file ActorMigration.php.

References $t, and SCHEMA_COMPAT_READ_OLD.

◆ getNewActorId()

ActorMigration::getNewActorId ( IDatabase  $dbw,
UserIdentity  $user 
)

Attempt to assign an actor ID to the given user.

If it is already assigned, return the existing ID.

Since
1.34.3
Parameters
IDatabase$dbw
UserIdentity$user
Returns
int The new actor ID

Definition at line 272 of file ActorMigration.php.

References Wikimedia\Rdbms\IDatabase\affectedRows(), MediaWiki\User\UserIdentity\getId(), MediaWiki\User\UserIdentity\getName(), Wikimedia\Rdbms\IDatabase\insert(), Wikimedia\Rdbms\IDatabase\insertId(), User\isUsableName(), and Wikimedia\Rdbms\IDatabase\selectField().

Referenced by getInsertValues().

◆ getWhere()

ActorMigration::getWhere ( IDatabase  $db,
  $key,
  $users,
  $useId = true 
)

Get WHERE condition for the actor.

Parameters
IDatabase$dbDatabase to use for quoting and list-making
string$keyA key such as "rev_user" identifying the actor field being fetched.
UserIdentity | UserIdentity[]$usersUsers to test for
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 three keys:
  • tables: (string[]) to include in the $table to IDatabase->select()
  • conds: (string) to include in the $cond to IDatabase->select()
  • 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() All tables and joins are aliased, so + is safe to use.

Definition at line 447 of file ActorMigration.php.

References $t, Wikimedia\Rdbms\IDatabase\makeList(), and SCHEMA_COMPAT_READ_NEW.

◆ isAnon()

ActorMigration::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 160 of file ActorMigration.php.

References SCHEMA_COMPAT_READ_NEW.

◆ isNotAnon()

ActorMigration::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 169 of file ActorMigration.php.

References SCHEMA_COMPAT_READ_NEW.

◆ newMigration()

Member Data Documentation

◆ $deprecated

string null [] ActorMigration::$deprecated
staticprivate
Initial value:
= [
'ar_user' => null,
'img_user' => null,
'oi_user' => null,
'fa_user' => null,
'rc_user' => null,
'log_user' => null,
'ipb_by' => null,
]

Define fields that are deprecated for use with this class.

Keys are '$key', value is null for soft deprecation or a string naming the deprecated version for hard deprecation.

Definition at line 79 of file ActorMigration.php.

◆ $formerTempTables

array ActorMigration::$formerTempTables = []
staticprivate

Fields that formerly used $tempTables Key is '$key', value is the MediaWiki version in which it was removed from $tempTables.

Definition at line 72 of file ActorMigration.php.

◆ $joinCache

array null ActorMigration::$joinCache = null
private

Cache for self::getJoin()

Definition at line 106 of file ActorMigration.php.

◆ $removed

string [] ActorMigration::$removed = []
staticprivate

Define fields that are removed for use with this class.

Keys are '$key', value is the MediaWiki version in which use was removed.

Definition at line 94 of file ActorMigration.php.

◆ $specialFields

array ActorMigration::$specialFields
staticprivate
Initial value:
= [
'ipb_by' => [ 'ipb_by_text', 'ipb_by_actor' ],
]

Define fields that use non-standard mapping Keys are the user id column name, values are arrays with two elements (the user text column name and the actor id column name)

Definition at line 101 of file ActorMigration.php.

◆ $stage

int ActorMigration::$stage
private

Combination of SCHEMA_COMPAT_* constants.

Definition at line 109 of file ActorMigration.php.

◆ $tempTables

array ActorMigration::$tempTables
staticprivate
Initial value:
= [
'rev_user' => [
'table' => 'revision_actor_temp',
'pk' => 'revactor_rev',
'field' => 'revactor_actor',
'joinPK' => 'rev_id',
'extra' => [
'revactor_timestamp' => 'rev_timestamp',
'revactor_page' => 'rev_page',
],
],
]

Define fields that use temporary tables for transitional purposes Keys are '$key', values are arrays with four fields:

  • table: Temporary table name
  • pk: Temporary table column referring to the main table's primary key
  • field: Temporary table column referring actor.actor_id
  • joinPK: Main table's primary key

Definition at line 54 of file ActorMigration.php.

◆ MIGRATION_STAGE_SCHEMA_COMPAT

const ActorMigration::MIGRATION_STAGE_SCHEMA_COMPAT = 1

Constant for extensions to feature-test whether $wgActorTableSchemaMigrationStage (in MW <1.34) expects MIGRATION_* or SCHEMA_COMPAT_*.

Definition at line 44 of file ActorMigration.php.


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