Opened 10 years ago
Closed 10 years ago
#36586 closed defect (bug) (fixed)
IXR_Value::isStruct() returns incorrectly for some arrays
| Reported by: | dd32 | Owned by: | ocean90 |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.6 |
| Component: | XML-RPC | Version: | |
| Severity: | normal | Keywords: | has-unit-tests |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
In 37244: