PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » XML » XML_Wddx » Bug #2118

PEAR Wddx is wrong with associative arrays

Details

Submitted2004-08-13 00:01 UTC
Fromez at daoldskool dot org
Assignedalan_k
StatusClosed
PackageXML_Wddx
PHP Version4.3.6
OSWindows / Linux
Roadmaps(Not assigned)

Comments

[2004-08-13 00:01 UTC] ez at daoldskool dot org

Description:
------------
PEAR Wddx library has a buggy data types handler

when serializing associative php arrays (collections/hash tables/dictionnaries...) with non strictly sequential numeric keys it is interpreting keys as indexes for normal real php arrays

as a result keys are lost

another minor bug is when dealing with numeric string

http://www.peoplemode.com/__dev/test/XML_wddx/PEAR/

Reproduce code:
---------------
http://www.peoplemode.com/__dev/test/XML_wddx/PEAR/

Expected result:
----------------
should have struct nodes

Actual result:
--------------
got array nodes instead and numeric keys are lost

[2004-08-13 01:31 UTC] ez at daoldskool dot org

sure Alan but you forgot the most important: _serializeValue

did you carefully take a look at the diff : http://www.peoplemode.com/__dev/test/XML_wddx/PEAR/index.php?debug=2&libdiff

what's the use of adding _isInt and _isAssoc private methods if you don't call them somewhere

besides your swith/case tests are always wrong:

switch (gettype($value)) {
case 'string':
...

you should have this instead:

switch (strtolower(gettype($value))) {
case 'string':
...

anyway my fixes in _serializeValue private methods don't need gettype anymore as it is not strictly reliable

best regards

Antonin

[2004-08-13 01:53 UTC] ez at daoldskool dot org

OK we do agree now.

Thanx for considering my bug submission.

Will you commit the changes in your next release ?

[2004-08-13 02:01 UTC] ez at daoldskool dot org

sure Alan

here is the test:

http://www.peoplemode.com/__dev/test/XML_wddx/PEAR/#code2

no more diffs

the array is now correctly serialized
and when re-serialize it again i got the full array back

;)

best regards

Antonin