X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FCommentStore.php;h=994a064f2cf4a5eab02eb5758a6fcf18f526a59a;hb=9283760f340c6971d748fb574a35453fa7928807;hp=7a2726f2917126ff162477fe5a4148370891fd4c;hpb=a8c5d918a2326d4cdce6ac308fe0350c34234b27;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/CommentStore.php b/includes/CommentStore.php index 7a2726f291..994a064f2c 100644 --- a/includes/CommentStore.php +++ b/includes/CommentStore.php @@ -70,11 +70,7 @@ class CommentStore { 'deprecatedIn' => null, ], 'img_description' => [ - 'table' => 'image_comment_temp', - 'pk' => 'imgcomment_name', - 'field' => 'imgcomment_description_id', - 'joinPK' => 'img_name', - 'stage' => MIGRATION_WRITE_NEW, + 'stage' => MIGRATION_NEW, 'deprecatedIn' => '1.32', ], ]; @@ -86,7 +82,11 @@ class CommentStore { */ protected $key = null; - /** @var int One of the MIGRATION_* constants */ + /** + * @var int One of the MIGRATION_* constants + * @todo Deprecate and remove once extensions seem unlikely to need to use + * it for migration anymore. + */ protected $stage; /** @var array[] Cache for `self::getJoin()` */ @@ -98,7 +98,8 @@ class CommentStore { /** * @param Language $lang Language to use for comment truncation. Defaults * to content language. - * @param int $migrationStage One of the MIGRATION_* constants + * @param int $migrationStage One of the MIGRATION_* constants. Always + * MIGRATION_NEW for MediaWiki core since 1.33. */ public function __construct( Language $lang, $migrationStage ) { $this->stage = $migrationStage; @@ -113,10 +114,10 @@ class CommentStore { * @return CommentStore */ public static function newKey( $key ) { - global $wgCommentTableSchemaMigrationStage; wfDeprecated( __METHOD__, '1.31' ); - $store = new CommentStore( MediaWikiServices::getInstance()->getContentLanguage(), - $wgCommentTableSchemaMigrationStage ); + $store = new CommentStore( + MediaWikiServices::getInstance()->getContentLanguage(), MIGRATION_NEW + ); $store->key = $key; return $store; } @@ -196,11 +197,12 @@ class CommentStore { * @since 1.31 Method signature changed, $key parameter added (with deprecated back compat) * @param string|null $key A key such as "rev_comment" identifying the comment * 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 = null ) { $key = $this->getKey( $key ); @@ -226,8 +228,14 @@ class CommentStore { if ( $tempTableStage === MIGRATION_OLD ) { $joinField = "{$alias}.{$t['field']}"; } else { + // Nothing hits this code path for now, but will in the future when we set + // $this->tempTables['rev_comment']['stage'] to MIGRATION_WRITE_NEW while + // merging revision_comment_temp into revision. + // @codeCoverageIgnoreStart $joins[$alias][0] = 'LEFT JOIN'; $joinField = "(CASE WHEN {$key}_id != 0 THEN {$key}_id ELSE {$alias}.{$t['field']} END)"; + throw new LogicException( 'Nothing should reach this code path at this time' ); + // @codeCoverageIgnoreEnd } } else { $joinField = "{$key}_id";