From:  pear-qa@lists.php.net ("dickson.michael@gmail.com")
Date:  12 Apr 2016 18:09:41 Hong Kong Time
Newsgroup:  news.php.net/php.pear.bugs
Subject:  

[PEAR-BUG] Bug #21052 [Com]: Incompatible Attributes Options

NNTP-Posting-Host:  null

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 at gmail dot 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:
---------------

You
We can be
friends

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"
  }
}

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


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