Bug #79528 [Opn->Nab]: Different object of the same xml between 7.4.5 and 7.4.4
| From: | requinix@php.net | Date: | Mon, 27 Apr 2020 07:48:03 +0000 |
| Subject: | Bug #79528 [Opn->Nab]: Different object of the same xml between 7.4.5 and 7.4.4 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226793@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79528&edit=1
ID: 79528
Updated by: requinix@php.net
Reported by: roke22 at gmail dot com
Summary: Different object of the same xml between 7.4.5 and
7.4.4
-Status: Open
+Status: Not a bug
Type: Bug
Package: SimpleXML related
Operating System: Linux
PHP Version: 7.4.5
Block user comment: N
Private report: N
New Comment:
The change in behavior is a result of a bug fix - see bug #61597.
The problem was that nodes with attributes were being treated as strings in cases that they should
not have been. Your example is one such case: the <value3> elements have attributes so simply
treating them as strings would lose that data.
Previous Comments:
------------------------------------------------------------------------
[2020-04-27 07:38:09] roke22 at gmail dot com
Description:
------------
---
From manual page: https://php.net/function.simplexml-load-string
---
We got different object when we read the same xml with php 7.4.4 and 7.4.5.
In php 7.4.4 we got a SimpleXMLElement object with an array.
In php 7.4.5 we got a SimpleXMLElement object with SimpleXMLElement objects.
This cause different behaviour on the same code. I think that in minor changes this have to be the
same result.
Test script:
---------------
<?php
$resultado = simplexml_load_string("<value1><value2><value3
valueinside='1'>17321</value3><value3
valueinside='2'>17321</value3></value2></value1>");
var_dump($resultado);
Expected result:
----------------
We expect the same resulto on both versions.
Actual result:
--------------
root@400e641ac608:/# php --version
PHP 7.4.5 (cli) (built: Apr 17 2020 11:29:12) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v2.9.4, Copyright (c) 2002-2020, by Derick Rethans
root@400e641ac608:/# cd /var/www/html/
root@400e641ac608:/var/www/html# php prueba.php
/var/www/html/prueba.php:3:
class SimpleXMLElement#1 (1) {
public $value2 =>
class SimpleXMLElement#2 (1) {
public $value3 =>
array(2) {
[0] =>
class SimpleXMLElement#3 (2) {
...
}
[1] =>
class SimpleXMLElement#4 (2) {
...
}
}
}
}
root@757c3e5e6b91:/var/www/html# php --version
PHP 7.4.4 (cli) (built: Apr 16 2020 15:22:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v2.9.4, Copyright (c) 2002-2020, by Derick Rethans
root@757c3e5e6b91:/var/www/html# php prueba.php
/var/www/html/prueba.php:3:
class SimpleXMLElement#1 (1) {
public $value2 =>
class SimpleXMLElement#2 (1) {
public $value3 =>
array(2) {
[0] =>
string(5) "17321"
[1] =>
string(5) "17321"
}
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79528&edit=1