[wp-trac] [WordPress Trac] #36586: IXR_Value::isStruct() returns incorrectly for some arrays
WordPress Trac
noreply at wordpress.org
Tue Apr 19 06:11:19 UTC 2016
#36586: IXR_Value::isStruct() returns incorrectly for some arrays
--------------------------+------------------------------
Reporter: dd32 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.6
Component: XML-RPC | Version:
Severity: normal | Keywords: needs-unit-tests
Focuses: |
--------------------------+------------------------------
Running the following code will result in a fatal error:
{{{
$value = new IXR_Value( array( '0.0' => 100 ) );
echo $value->getXML();
}}}
This doesn't apply to a case such as `[ '0.0' => 1, 'two' => 2 ]` or `[
'one', 'others' => 3 ]`, only when an array has a single `0.0` key.
The issue is that `IXR_Value::isStruct()` detects this as a numerically
indexed array, which it isn't.
The fix is simple, replacing `!=` with `!==` so that `"0.0" !== "0"` is
truthful, so that it detects it as a struct (a non-numeric array).
Another option is to replace it with a call to `wp_is_numeric_array()`,
but since this is an external it makes sense to just make the single-
character change.
Unfortunately I can't find the upstream to submit this to, other than
[http://scripts.incutio.com/xmlrpc/ contacting incutio] directly and none
of the recent forks appear to add anything of value.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36586>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list