Opened 10 years ago
Closed 10 years ago
#36586 closed defect (bug) (fixed)
IXR_Value::isStruct() returns incorrectly for some arrays
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.6 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | XML-RPC | Keywords: | has-unit-tests |
| Focuses: | Cc: |
Description
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 contacting incutio directly and none of the recent forks appear to add anything of value.
In 37244: