FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=21052&edit=1

  ID: 21052
  Comment by: dickson.michael@gmail.com
  Reported By: dickson dot michael@gmail.com
  Summary: Incompatible Attributes Options
  Status: Open
  Type: Bug
  Package: XML_Serializer
  Package Version: 0.20.2
  PHP Version: Irrelevant
  Roadmap Versions:
  New Comment:

I found the above patch solves the problem by creating a $dataAttribs
which does not contain the internal attributes _originalKey, _type, or
_class.


Previous Comments:
------------------------------------------------------------------------

[2016-04-12 06:05:59] dicksonm

Added #patch
bug:21052;patch:attribute-segregation.patch;revision:1460455559;.

------------------------------------------------------------------------

[2016-04-12 05:59:42] dicksonm

Description:
------------
In Unserialize.php, when 'parseAttributes' is set as well as 'typeHints'
the
output data is corrupted by package's internal attributes.

Test script:
---------------
<?php
$string = <<<EOD
<array _type="array" Hello="world" Glad="I am">
<XML_Serializer_Tag _originalKey="To see"
_type="string">You</XML_Serializer_Tag>
<XML_Serializer_Tag _originalKey="I think" _type="string">We can be
friends</XML_Serializer_Tag>
</array>
EOD;

require_once 'XML/Unserializer.php';
$engine = new XML_Unserializer();
$engine->setOption('parseAttributes', true);
$engine->setOption('typeHints', TRUE);
$engine->unserialize($string);
var_dump($engine->getUnserializedData());
?>

Expected result:
----------------
array(4) {
   ["Hello"]=>
   string(5) "world"
   ["Glad"]=>
   string(4) "I am"
   ["To see"]=>
   string(3) "You"
   ["I think"]=>
   string(17) "We can be friends"
}


Actual result:
--------------
array(5) {
   ["_type"]=>
   string(5) "array"
   ["Hello"]=>
   string(5) "world"
   ["Glad"]=>
   string(4) "I am"
   [0]=>
   array(3) {
     ["_originalKey"]=>
     string(6) "To see"
     ["_type"]=>
     string(6) "string"
     ["_content"]=>
     string(3) "You"
   }
   [1]=>
   array(3) {
     ["_originalKey"]=>
     string(7) "I think"
     ["_type"]=>
     string(6) "string"
     ["_content"]=>
     string(17) "We can be friends"
   }
}

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedApr 12, '16 at 10:08a
activeApr 12, '16 at 10:08a
posts1
users1
websitepear.php.net

1 user in discussion

Dickson Michael: 1 post

People

Translate

site design / logo © 2022 Grokbase