[PHP-DEV] PHP 5.3 bug or changed feature??  
Author Message
frank





PostPosted: 2007-12-8 6:11:11 Top

php-dev, [PHP-DEV] PHP 5.3 bug or changed feature?? Hello Everyon,

Casting a SimpleXML object to an array gives different results in PHP
5.2.5 and PHP 5.3-dev.

Source:

$xml = simplexml_load_file("sample.xml");

foreach($xml->column as $column) {
var_dump($column);
var_dump((array)$column);
}

sample.xml

?xml version="1.0"?>
<cpdata>
<column name="ENTERTAINMENT">
<module>cv</module>
<module>entsimp</module>
</column>
<column name="SEAT CONTROL">
<module>pp</module>
<module>sc</module>
</column>
</cpdata>

PHP 5.2 output:
object(SimpleXMLElement)#4 (2) {
["@attributes"]=>
array(1) {
["name"]=>
string(13) "ENTERTAINMENT"
}
["module"]=>
array(2) {
[0]=>
string(2) "cv"
[1]=>
string(7) "entsimp"
}
}
array(2) {
["@attributes"]=>
array(1) {
["name"]=>
string(13) "ENTERTAINMENT"
}
["module"]=>
array(2) {
[0]=>
string(2) "cv"
[1]=>
string(7) "entsimp"
}
}
object(SimpleXMLElement)#5 (2) {
["@attributes"]=>
array(1) {
["name"]=>
string(12) "SEAT CONTROL"
}
["module"]=>
array(2) {
[0]=>
string(2) "pp"
[1]=>
string(2) "sc"
}
}
array(2) {
["@attributes"]=>
array(1) {
["name"]=>
string(12) "SEAT CONTROL"
}
["module"]=>
array(2) {
[0]=>
string(2) "pp"
[1]=>
string(2) "sc"
}
}

PHP 5.3 output:

object(SimpleXMLElement)#4 (2) {
["@attributes"]=>
array(1) {
["name"]=>
string(13) "ENTERTAINMENT"
}
["module"]=>
array(2) {
[0]=>
string(2) "cv"
[1]=>
string(7) "entsimp"
}
}
array(1) {
["module"]=>
array(2) {
[0]=>
string(2) "cv"
[1]=>
string(7) "entsimp"
}
}
object(SimpleXMLElement)#5 (2) {
["@attributes"]=>
array(1) {
["name"]=>
string(12) "SEAT CONTROL"
}
["module"]=>
array(2) {
[0]=>
string(2) "pp"
[1]=>
string(2) "sc"
}
}
array(1) {
["module"]=>
array(2) {
[0]=>
string(2) "pp"
[1]=>
string(2) "sc"
}
}

Not that the attributes are gone when SimpleXML objects are converted in
PHP 5.3. Is this a bug or a feature change?

- Frank

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

 
marco.kaiser





PostPosted: 2007-12-9 4:16:00 Top

php-dev >> [PHP-DEV] PHP 5.3 bug or changed feature?? ------=_Part_2604_25799081.1197144924691
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi Frank,

please open a bugreport about this issue. This would start the internal
process of verifying this.

-- Marco

On Dec 7, 2007 11:09 PM, Frank M. Kromann <email***@***.com> wrote:

> Hello Everyon,
>
> Casting a SimpleXML object to an array gives different results in PHP
> 5.2.5 and PHP 5.3-dev.
>
> Source:
>
> $xml = simplexml_load_file("sample.xml");
>
> foreach($xml->column as $column) {
> var_dump($column);
> var_dump((array)$column);
> }
>
> sample.xml
>
> ?xml version="1.0"?>
> <cpdata>
> <column name="ENTERTAINMENT">
> <module>cv</module>
> <module>entsimp</module>
> </column>
> <column name="SEAT CONTROL">
> <module>pp</module>
> <module>sc</module>
> </column>
> </cpdata>
>
> PHP 5.2 output:
> object(SimpleXMLElement)#4 (2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(13) "ENTERTAINMENT"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "cv"
> [1]=>
> string(7) "entsimp"
> }
> }
> array(2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(13) "ENTERTAINMENT"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "cv"
> [1]=>
> string(7) "entsimp"
> }
> }
> object(SimpleXMLElement)#5 (2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(12) "SEAT CONTROL"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "pp"
> [1]=>
> string(2) "sc"
> }
> }
> array(2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(12) "SEAT CONTROL"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "pp"
> [1]=>
> string(2) "sc"
> }
> }
>
> PHP 5.3 output:
>
> object(SimpleXMLElement)#4 (2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(13) "ENTERTAINMENT"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "cv"
> [1]=>
> string(7) "entsimp"
> }
> }
> array(1) {
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "cv"
> [1]=>
> string(7) "entsimp"
> }
> }
> object(SimpleXMLElement)#5 (2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(12) "SEAT CONTROL"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "pp"
> [1]=>
> string(2) "sc"
> }
> }
> array(1) {
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "pp"
> [1]=>
> string(2) "sc"
> }
> }
>
> Not that the attributes are gone when SimpleXML objects are converted in
> PHP 5.3. Is this a bug or a feature change?
>
> - Frank
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Marco Kaiser

------=_Part_2604_25799081.1197144924691--
 
rrichards





PostPosted: 2007-12-9 20:25:00 Top

php-dev >> [PHP-DEV] PHP 5.3 bug or changed feature?? Hi Frank,

Frank M. Kromann wrote:
> Hello Everyon,
>
> Casting a SimpleXML object to an array gives different results in PHP
> 5.2.5 and PHP 5.3-dev.
>
This is due to the implementation of the get_debug_info handler merged
from HEAD.
The same result happens when calling get_object_vars on a
SimpleXMLElement object.

Marcus, was it intended to only include @attributes with print_r/var_dump?

Rob
> Source:
>
> $xml = simplexml_load_file("sample.xml");
>
> foreach($xml->column as $column) {
> var_dump($column);
> var_dump((array)$column);
> }
>
> sample.xml
>
> ?xml version="1.0"?>
> <cpdata>
> <column name="ENTERTAINMENT">
> <module>cv</module>
> <module>entsimp</module>
> </column>
> <column name="SEAT CONTROL">
> <module>pp</module>
> <module>sc</module>
> </column>
> </cpdata>
>
> PHP 5.2 output:
> object(SimpleXMLElement)#4 (2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(13) "ENTERTAINMENT"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "cv"
> [1]=>
> string(7) "entsimp"
> }
> }
> array(2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(13) "ENTERTAINMENT"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "cv"
> [1]=>
> string(7) "entsimp"
> }
> }
> object(SimpleXMLElement)#5 (2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(12) "SEAT CONTROL"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "pp"
> [1]=>
> string(2) "sc"
> }
> }
> array(2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(12) "SEAT CONTROL"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "pp"
> [1]=>
> string(2) "sc"
> }
> }
>
> PHP 5.3 output:
>
> object(SimpleXMLElement)#4 (2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(13) "ENTERTAINMENT"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "cv"
> [1]=>
> string(7) "entsimp"
> }
> }
> array(1) {
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "cv"
> [1]=>
> string(7) "entsimp"
> }
> }
> object(SimpleXMLElement)#5 (2) {
> ["@attributes"]=>
> array(1) {
> ["name"]=>
> string(12) "SEAT CONTROL"
> }
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "pp"
> [1]=>
> string(2) "sc"
> }
> }
> array(1) {
> ["module"]=>
> array(2) {
> [0]=>
> string(2) "pp"
> [1]=>
> string(2) "sc"
> }
> }
>
> Not that the attributes are gone when SimpleXML objects are converted in
> PHP 5.3. Is this a bug or a feature change?
>
> - Frank
>
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

 
 
marco.kaiser





PostPosted: 2007-12-9 21:53:00 Top

php-dev >> [PHP-DEV] PHP 5.3 bug or changed feature?? ------=_Part_2819_3376365.1197208318313
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

This happens with many more functions. So i can verify this bug.

php -r "echo md5(serialize(simplexml_load_file('example.xml'))) . PHP_EOL .
phpversion() . PHP_EOL;"

Output PHP 5.2.5:
a6d7776fcb0e9c085b0d5972df792dac
5.2.5

Output PHP 5.3.0-dev (latest snap)
3e442cb7c8507c8941011735bb46e6de
5.3.0-dev

-- Marco

On Dec 9, 2007 1:22 PM, Rob Richards <email***@***.com> wrote:

> Hi Frank,
>
> Frank M. Kromann wrote:
> > Hello Everyon,
> >
> > Casting a SimpleXML object to an array gives different results in PHP
> > 5.2.5 and PHP 5.3-dev.
> >
> This is due to the implementation of the get_debug_info handler merged
> from HEAD.
> The same result happens when calling get_object_vars on a
> SimpleXMLElement object.
>
> Marcus, was it intended to only include @attributes with print_r/var_dump?
>
> Rob
> > Source:
> >
> > $xml = simplexml_load_file("sample.xml");
> >
> > foreach($xml->column as $column) {
> > var_dump($column);
> > var_dump((array)$column);
> > }
> >
> > sample.xml
> >
> > ?xml version="1.0"?>
> > <cpdata>
> > <column name="ENTERTAINMENT">
> > <module>cv</module>
> > <module>entsimp</module>
> > </column>
> > <column name="SEAT CONTROL">
> > <module>pp</module>
> > <module>sc</module>
> > </column>
> > </cpdata>
> >
> > PHP 5.2 output:
> > object(SimpleXMLElement)#4 (2) {
> > ["@attributes"]=>
> > array(1) {
> > ["name"]=>
> > string(13) "ENTERTAINMENT"
> > }
> > ["module"]=>
> > array(2) {
> > [0]=>
> > string(2) "cv"
> > [1]=>
> > string(7) "entsimp"
> > }
> > }
> > array(2) {
> > ["@attributes"]=>
> > array(1) {
> > ["name"]=>
> > string(13) "ENTERTAINMENT"
> > }
> > ["module"]=>
> > array(2) {
> > [0]=>
> > string(2) "cv"
> > [1]=>
> > string(7) "entsimp"
> > }
> > }
> > object(SimpleXMLElement)#5 (2) {
> > ["@attributes"]=>
> > array(1) {
> > ["name"]=>
> > string(12) "SEAT CONTROL"
> > }
> > ["module"]=>
> > array(2) {
> > [0]=>
> > string(2) "pp"
> > [1]=>
> > string(2) "sc"
> > }
> > }
> > array(2) {
> > ["@attributes"]=>
> > array(1) {
> > ["name"]=>
> > string(12) "SEAT CONTROL"
> > }
> > ["module"]=>
> > array(2) {
> > [0]=>
> > string(2) "pp"
> > [1]=>
> > string(2) "sc"
> > }
> > }
> >
> > PHP 5.3 output:
> >
> > object(SimpleXMLElement)#4 (2) {
> > ["@attributes"]=>
> > array(1) {
> > ["name"]=>
> > string(13) "ENTERTAINMENT"
> > }
> > ["module"]=>
> > array(2) {
> > [0]=>
> > string(2) "cv"
> > [1]=>
> > string(7) "entsimp"
> > }
> > }
> > array(1) {
> > ["module"]=>
> > array(2) {
> > [0]=>
> > string(2) "cv"
> > [1]=>
> > string(7) "entsimp"
> > }
> > }
> > object(SimpleXMLElement)#5 (2) {
> > ["@attributes"]=>
> > array(1) {
> > ["name"]=>
> > string(12) "SEAT CONTROL"
> > }
> > ["module"]=>
> > array(2) {
> > [0]=>
> > string(2) "pp"
> > [1]=>
> > string(2) "sc"
> > }
> > }
> > array(1) {
> > ["module"]=>
> > array(2) {
> > [0]=>
> > string(2) "pp"
> > [1]=>
> > string(2) "sc"
> > }
> > }
> >
> > Not that the attributes are gone when SimpleXML objects are converted in
> > PHP 5.3. Is this a bug or a feature change?
> >
> > - Frank
> >
> >
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Marco Kaiser

------=_Part_2819_3376365.1197208318313--
 
 
helly





PostPosted: 2007-12-11 5:02:00 Top

php-dev >> [PHP-DEV] PHP 5.3 bug or changed feature?? Hello Rob,

this is intended. The 5.2 solution is just a hack and returns a wrong
result in the first place. The hack was however introduced to make
development easier. Now with 5.3 we were able to change the API and coudl
apply the solution that was first developed in HEAD.

marcus

Sunday, December 9, 2007, 1:22:09 PM, you wrote:

> Hi Frank,

> Frank M. Kromann wrote:
>> Hello Everyon,
>>
>> Casting a SimpleXML object to an array gives different results in PHP
>> 5.2.5 and PHP 5.3-dev.
>>
> This is due to the implementation of the get_debug_info handler merged
> from HEAD.
> The same result happens when calling get_object_vars on a
> SimpleXMLElement object.

> Marcus, was it intended to only include @attributes with print_r/var_dump?

> Rob
>> Source:
>>
>> $xml = simplexml_load_file("sample.xml");
>>
>> foreach($xml->column as $column) {
>> var_dump($column);
>> var_dump((array)$column);
>> }
>>
>> sample.xml
>>
>> ?xml version="1.0"?>
>> <cpdata>
>> <column name="ENTERTAINMENT">
>> <module>cv</module>
>> <module>entsimp</module>
>> </column>
>> <column name="SEAT CONTROL">
>> <module>pp</module>
>> <module>sc</module>
>> </column>
>> </cpdata>
>>
>> PHP 5.2 output:
>> object(SimpleXMLElement)#4 (2) {
>> ["@attributes"]=>
>> array(1) {
>> ["name"]=>
>> string(13) "ENTERTAINMENT"
>> }
>> ["module"]=>
>> array(2) {
>> [0]=>
>> string(2) "cv"
>> [1]=>
>> string(7) "entsimp"
>> }
>> }
>> array(2) {
>> ["@attributes"]=>
>> array(1) {
>> ["name"]=>
>> string(13) "ENTERTAINMENT"
>> }
>> ["module"]=>
>> array(2) {
>> [0]=>
>> string(2) "cv"
>> [1]=>
>> string(7) "entsimp"
>> }
>> }
>> object(SimpleXMLElement)#5 (2) {
>> ["@attributes"]=>
>> array(1) {
>> ["name"]=>
>> string(12) "SEAT CONTROL"
>> }
>> ["module"]=>
>> array(2) {
>> [0]=>
>> string(2) "pp"
>> [1]=>
>> string(2) "sc"
>> }
>> }
>> array(2) {
>> ["@attributes"]=>
>> array(1) {
>> ["name"]=>
>> string(12) "SEAT CONTROL"
>> }
>> ["module"]=>
>> array(2) {
>> [0]=>
>> string(2) "pp"
>> [1]=>
>> string(2) "sc"
>> }
>> }
>>
>> PHP 5.3 output:
>>
>> object(SimpleXMLElement)#4 (2) {
>> ["@attributes"]=>
>> array(1) {
>> ["name"]=>
>> string(13) "ENTERTAINMENT"
>> }
>> ["module"]=>
>> array(2) {
>> [0]=>
>> string(2) "cv"
>> [1]=>
>> string(7) "entsimp"
>> }
>> }
>> array(1) {
>> ["module"]=>
>> array(2) {
>> [0]=>
>> string(2) "cv"
>> [1]=>
>> string(7) "entsimp"
>> }
>> }
>> object(SimpleXMLElement)#5 (2) {
>> ["@attributes"]=>
>> array(1) {
>> ["name"]=>
>> string(12) "SEAT CONTROL"
>> }
>> ["module"]=>
>> array(2) {
>> [0]=>
>> string(2) "pp"
>> [1]=>
>> string(2) "sc"
>> }
>> }
>> array(1) {
>> ["module"]=>
>> array(2) {
>> [0]=>
>> string(2) "pp"
>> [1]=>
>> string(2) "sc"
>> }
>> }
>>
>> Not that the attributes are gone when SimpleXML objects are converted in
>> PHP 5.3. Is this a bug or a feature change?
>>
>> - Frank
>>
>>




Best regards,
Marcus

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

 
 
frank





PostPosted: 2007-12-11 6:09:00 Top

php-dev >> [PHP-DEV] PHP 5.3 bug or changed feature?? Hi Marcus,

Will there be another way to do this or will they only be accessible from
the object?

- Frank

> Hello Rob,
>
> this is intended. The 5.2 solution is just a hack and returns a wrong
> result in the first place. The hack was however introduced to make
> development easier. Now with 5.3 we were able to change the API and
coudl
> apply the solution that was first developed in HEAD.
>
> marcus
>
> Sunday, December 9, 2007, 1:22:09 PM, you wrote:
>
> > Hi Frank,
>
> > Frank M. Kromann wrote:
> >> Hello Everyon,
> >>
> >> Casting a SimpleXML object to an array gives different results in
PHP
> >> 5.2.5 and PHP 5.3-dev.
> >>
> > This is due to the implementation of the get_debug_info handler merged

> > from HEAD.
> > The same result happens when calling get_object_vars on a
> > SimpleXMLElement object.
>
> > Marcus, was it intended to only include @attributes with
print_r/var_dump?
>
> > Rob
> >> Source:
> >>
> >> $xml = simplexml_load_file("sample.xml");
> >>
> >> foreach($xml->column as $column) {
> >> var_dump($column);
> >> var_dump((array)$column);
> >> }
> >>
> >> sample.xml
> >>
> >> ?xml version="1.0"?>
> >> <cpdata>
> >> <column name="ENTERTAINMENT">
> >> <module>cv</module>
> >> <module>entsimp</module>
> >> </column>
> >> <column name="SEAT CONTROL">
> >> <module>pp</module>
> >> <module>sc</module>
> >> </column>
> >> </cpdata>
> >>
> >> PHP 5.2 output:
> >> object(SimpleXMLElement)#4 (2) {
> >> ["@attributes"]=>
> >> array(1) {
> >> ["name"]=>
> >> string(13) "ENTERTAINMENT"
> >> }
> >> ["module"]=>
> >> array(2) {
> >> [0]=>
> >> string(2) "cv"
> >> [1]=>
> >> string(7) "entsimp"
> >> }
> >> }
> >> array(2) {
> >> ["@attributes"]=>
> >> array(1) {
> >> ["name"]=>
> >> string(13) "ENTERTAINMENT"
> >> }
> >> ["module"]=>
> >> array(2) {
> >> [0]=>
> >> string(2) "cv"
> >> [1]=>
> >> string(7) "entsimp"
> >> }
> >> }
> >> object(SimpleXMLElement)#5 (2) {
> >> ["@attributes"]=>
> >> array(1) {
> >> ["name"]=>
> >> string(12) "SEAT CONTROL"
> >> }
> >> ["module"]=>
> >> array(2) {
> >> [0]=>
> >> string(2) "pp"
> >> [1]=>
> >> string(2) "sc"
> >> }
> >> }
> >> array(2) {
> >> ["@attributes"]=>
> >> array(1) {
> >> ["name"]=>
> >> string(12) "SEAT CONTROL"
> >> }
> >> ["module"]=>
> >> array(2) {
> >> [0]=>
> >> string(2) "pp"
> >> [1]=>
> >> string(2) "sc"
> >> }
> >> }
> >>
> >> PHP 5.3 output:
> >>
> >> object(SimpleXMLElement)#4 (2) {
> >> ["@attributes"]=>
> >> array(1) {
> >> ["name"]=>
> >> string(13) "ENTERTAINMENT"
> >> }
> >> ["module"]=>
> >> array(2) {
> >> [0]=>
> >> string(2) "cv"
> >> [1]=>
> >> string(7) "entsimp"
> >> }
> >> }
> >> array(1) {
> >> ["module"]=>
> >> array(2) {
> >> [0]=>
> >> string(2) "cv"
> >> [1]=>
> >> string(7) "entsimp"
> >> }
> >> }
> >> object(SimpleXMLElement)#5 (2) {
> >> ["@attributes"]=>
> >> array(1) {
> >> ["name"]=>
> >> string(12) "SEAT CONTROL"
> >> }
> >> ["module"]=>
> >> array(2) {
> >> [0]=>
> >> string(2) "pp"
> >> [1]=>
> >> string(2) "sc"
> >> }
> >> }
> >> array(1) {
> >> ["module"]=>
> >> array(2) {
> >> [0]=>
> >> string(2) "pp"
> >> [1]=>
> >> string(2) "sc"
> >> }
> >> }
> >>
> >> Not that the attributes are gone when SimpleXML objects are converted
in
> >> PHP 5.3. Is this a bug or a feature change?
> >>
> >> - Frank
> >>
> >>
>
>
>
>
> Best regards,
> Marcus
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php