Revert "API: Work around PHP bug 45959"

This reverts commit 8deb49f534.

The added tests are left in place to avoid regression.

There's no longer a need for the workaround,
https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts

It requires PHP 7.2 which seems like it would be ok,
https://www.mediawiki.org/wiki/Compatibility#PHP

Bug: T123663
Change-Id: I09cef8acb71bbeee262b982780a8b9fb3935fb4e
This commit is contained in:
Arlo Breault 2021-09-02 13:41:56 -04:00
parent 989527911f
commit b38114c890

View file

@ -358,13 +358,9 @@ class ApiResult implements ApiSerializable {
}
$value = $contentLanguage->normalize( $value );
} elseif ( is_array( $value ) ) {
// Work around https://bugs.php.net/bug.php?id=45959 by copying to a temporary
// (in this case, foreach gets $k === "1" but $tmp[$k] assigns as if $k === 1)
$tmp = [];
foreach ( $value as $k => $v ) {
$tmp[$k] = self::validateValue( $v );
$value[$k] = self::validateValue( $v );
}
$value = $tmp;
} elseif ( $value !== null && !is_scalar( $value ) ) {
$type = gettype( $value );
if ( is_resource( $value ) ) {