diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 626aef000d6..51b1e127e2d 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -196,7 +196,8 @@ class ApiQueryImageInfo extends ApiQueryBase { $info['badfile'] = (bool)$this->badFileLookup->isBadFile( $title, $badFileContextTitle ); } - $fit = $result->addValue( [ 'query', 'pages' ], (int)$pageId, $info ); + // Use ApiResult::IGNORE_CONFLICT_KEYS, the module is extended and the value can be set twice (T402438) + $fit = $result->addValue( [ 'query', 'pages' ], (int)$pageId, $info, ApiResult::IGNORE_CONFLICT_KEYS ); if ( !$fit ) { if ( count( $pageIds[NS_FILE] ) == 1 ) { // The user is screwed. imageinfo can't be solely diff --git a/includes/api/ApiResult.php b/includes/api/ApiResult.php index ff1c4b4cb62..7b85d12f594 100644 --- a/includes/api/ApiResult.php +++ b/includes/api/ApiResult.php @@ -73,6 +73,13 @@ class ApiResult implements ApiSerializable { */ public const NO_VALIDATE = self::NO_SIZE_CHECK | 8; + /** + * For addValue(), setValue() and similar functions, do allow override + * of conflicting keys. + * @since 1.45 (also backported to 1.43.6, 1.44.3) + */ + public const IGNORE_CONFLICT_KEYS = 16; + /** * Key for the 'indexed tag name' metadata item. Value is string. * @since 1.25 @@ -309,7 +316,7 @@ class ApiResult implements ApiSerializable { } } elseif ( is_array( $arr[$name] ) && is_array( $value ) ) { $conflicts = array_intersect_key( $arr[$name], $value ); - if ( !$conflicts ) { + if ( !$conflicts || ( $flags & self::IGNORE_CONFLICT_KEYS ) ) { $arr[$name] += $value; } else { $keys = implode( ', ', array_keys( $conflicts ) );