Bug #74203 [NEW]: unset on SimpleXMLElement not working

From: Date: Sat, 04 Mar 2017 11:22:51 +0000
Subject: Bug #74203 [NEW]: unset on SimpleXMLElement not working
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207679@lists.php.net to get a copy of this message
From: alepane at gmail dot com Operating system: macOS and linux PHP version: 7.0.16 Package: SimpleXML related Bug Type: Bug Bug description:unset on SimpleXMLElement not working Description: ------------ The instruction unset($seg_ref->{0}) works in PHP5.6 but not in PHP7 ... I haven't found this behaviour's change in any doc, so it's probably a bug. The attached example in PHP 5.6 returns the dom without <seg id="A1"/>, in PHP 7 returns also that element (so the unset is not working). Using $seg_ref[0] works in both version. Test script: --------------- <?php $data='<data> <seg id="A1"/> <seg id="A2"/> <seg id="A3"/> <seg id="A4"/> <seg id="A5"/> </data>'; $doc=new SimpleXMLElement($data); $seg_ref = $doc->seg; unset($seg_ref->{0}); echo $doc->asXml(); Expected result: ---------------- <data> <seg id="A2"/> <seg id="A3"/> <seg id="A4"/> <seg id="A5"/> </data> Actual result: -------------- <data> <seg id="A1"/> <seg id="A2"/> <seg id="A3"/> <seg id="A4"/> <seg id="A5"/> </data> -- Edit bug report at https://bugs.php.net/bug.php?id=74203&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74203&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74203&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74203&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74203&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74203&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74203&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74203&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74203&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74203&r=support Expected behavior: https://bugs.php.net/fix.php?id=74203&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74203&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74203&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74203&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74203&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74203&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74203&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74203&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74203&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74203&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74203&r=mysqlcfg

« previous php.bugs (#207679) next »