api: Allow ApiResult to override imagerepository key in prop=imageinfo
prop=videoinfo also set this key, using both results in error Needs a new flag as ApiResult::OVERRIDE override the whole result array of the given sub key and not only conflicting keys. Bug: T402438 Change-Id: I17e8e2f35c713e9ed6169255113e888ffdb9ea12 (cherry picked from commit c94b6ced5d653204bb590ba5d767650f74d93be4)
This commit is contained in:
parent
953952abc9
commit
42eebc2aee
2 changed files with 10 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 ) );
|
||||
|
|
|
|||
Loading…
Reference in a new issue