ParserOutput::mergeMapStrategy - use a more robust comparison for objects
Map values can include JsonUnserializable objects, and strict (reference) equality comparison of these objects is not going to reflect value equality. Serialize the values and compare strings instead; this case should be hit very infrequently given that rewriting the same extension data key is discouraged. Bug: T312588 Change-Id: I942e7fa662b2f1a5e32fd55ef65eaa10a22afcfb
This commit is contained in:
parent
f5ba3b2e8e
commit
541542e588
1 changed files with 14 additions and 4 deletions
|
|
@ -2346,10 +2346,20 @@ class ParserOutput extends CacheTime implements ContentMetadataCollector {
|
|||
} else {
|
||||
throw new InvalidArgumentException( "Unknown merge strategy $strategy" );
|
||||
}
|
||||
} elseif ( $a[$key] !== $bValue ) {
|
||||
// Silently replace for now; in the future will first emit
|
||||
// a deprecation warning, and then (later) throw.
|
||||
$a[$key] = $bValue;
|
||||
} else {
|
||||
$valuesSame = ( $a[$key] === $bValue );
|
||||
if ( ( !$valuesSame ) &&
|
||||
is_object( $a[$key] ) &&
|
||||
is_object( $bValue )
|
||||
) {
|
||||
$jsonCodec = MediaWikiServices::getInstance()->getJsonCodec();
|
||||
$valuesSame = ( $jsonCodec->serialize( $a[$key] ) === $jsonCodec->serialize( $bValue ) );
|
||||
}
|
||||
if ( !$valuesSame ) {
|
||||
// Silently replace for now; in the future will first emit
|
||||
// a deprecation warning, and then (later) throw.
|
||||
$a[$key] = $bValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $a;
|
||||
|
|
|
|||
Loading…
Reference in a new issue