X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FActorMigration.php;h=c79074df7565b2380667b5fcbd14002c5afff8cc;hb=d6ed082b6d66adfc5f603d8b573deaef83d4e045;hp=597b8e76e79e06bbe0245bea7b3e7deb4e0fac94;hpb=7f2f49ad2368ae27f2d4db69b44c5f997197725e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ActorMigration.php b/includes/ActorMigration.php index 597b8e76e7..c79074df75 100644 --- a/includes/ActorMigration.php +++ b/includes/ActorMigration.php @@ -28,15 +28,18 @@ use Wikimedia\Rdbms\IDatabase; * 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 along with $wgActorTableSchemaMigrationStage. + * 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. */ class ActorMigration { /** * Constant for extensions to feature-test whether $wgActorTableSchemaMigrationStage - * expects MIGRATION_* or SCHEMA_COMPAT_* + * (in MW <1.34) expects MIGRATION_* or SCHEMA_COMPAT_* */ const MIGRATION_STAGE_SCHEMA_COMPAT = 1; @@ -68,6 +71,28 @@ class ActorMigration { */ private static $formerTempTables = []; + /** + * Define fields that are deprecated for use with this class. + * @var (string|null)[] Keys are '$key', value is null for soft deprecation + * or a string naming the deprecated version for hard deprecation. + */ + private static $deprecated = [ + 'ar_user' => null, // 1.34 + 'img_user' => null, // 1.34 + 'oi_user' => null, // 1.34 + 'fa_user' => null, // 1.34 + 'rc_user' => null, // 1.34 + 'log_user' => null, // 1.34 + 'ipb_by' => null, // 1.34 + ]; + + /** + * Define fields that are removed for use with this class. + * @var string[] Keys are '$key', value is the MediaWiki version in which + * use was removed. + */ + private static $removed = []; + /** * Define fields that use non-standard mapping * @var array Keys are the user id column name, values are arrays with two @@ -112,6 +137,21 @@ class ActorMigration { return MediaWikiServices::getInstance()->getActorMigration(); } + /** + * Issue deprecation warning/error as appropriate. + * @param string $key + */ + private static function checkDeprecation( $key ) { + if ( isset( self::$removed[$key] ) ) { + throw new InvalidArgumentException( + "Use of " . static::class . " for '$key' was removed in MediaWiki " . self::$removed[$key] + ); + } + if ( !empty( self::$deprecated[$key] ) ) { + wfDeprecated( static::class . " for '$key'", self::$deprecated[$key], false, 3 ); + } + } + /** * Return an SQL condition to test if a user field is anonymous * @param string $field Field name or SQL fragment @@ -144,13 +184,16 @@ class ActorMigration { * * @param string $key A key such as "rev_user" identifying the actor * field being fetched. - * @return array With three keys: + * @return 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. + * @phan-return array{tables:string[],fields:string[],joins:array} */ public function getJoin( $key ) { + self::checkDeprecation( $key ); + if ( !isset( $this->joinCache[$key] ) ) { $tables = []; $fields = []; @@ -202,6 +245,8 @@ class ActorMigration { * @return array to merge into `$values` to `IDatabase->update()` or `$a` to `IDatabase->insert()` */ public function getInsertValues( IDatabase $dbw, $key, UserIdentity $user ) { + self::checkDeprecation( $key ); + if ( isset( self::$tempTables[$key] ) ) { throw new InvalidArgumentException( "Must use getInsertValuesWithTempTable() for $key" ); } @@ -235,6 +280,8 @@ class ActorMigration { * and extra fields needed for the temp table. */ public function getInsertValuesWithTempTable( IDatabase $dbw, $key, UserIdentity $user ) { + self::checkDeprecation( $key ); + if ( isset( self::$formerTempTables[$key] ) ) { wfDeprecated( __METHOD__ . " for $key", self::$formerTempTables[$key] ); } elseif ( !isset( self::$tempTables[$key] ) ) { @@ -318,6 +365,8 @@ class ActorMigration { * All tables and joins are aliased, so `+` is safe to use. */ public function getWhere( IDatabase $db, $key, $users, $useId = true ) { + self::checkDeprecation( $key ); + $tables = []; $conds = []; $joins = [];