#39760 [NEW]: cloning fails on nested SimpleXML-Object

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #39760 [NEW]: cloning fails on nested SimpleXML-Object

    From: saschagros at bluewin dot ch
    Operating system: Windows/Linux
    PHP version: 5.2.0
    PHP Bug Type: SimpleXML related
    Bug description: cloning fails on nested SimpleXML-Object

    Description:
    ------------
    "clone $simpleXML->subElement1->subElement2" does not work as excepted.

    It does not return a clone of itself but a clone of it's parent.

    Tested on:
    Windows with PHP 5.2.0
    Linux with PHP 5.2.0
    Linux with PHP 5.0.4

    Reproduce code:
    ---------------
    $xml = '<?xml version="1.0" ?>
    <test>
    <level1>
    <level2a>text1</level2a>
    <level2b>text2</level2b>
    </level1>
    </test>';
    $test = simplexml_load_string($xml);

    print_r($test->level1->level2a);

    $test2 = clone $test;
    print_r($test2->level1->level2a);

    $test3 = clone $test->level1->level2a;
    print_r($test3);

    Expected result:
    ----------------
    SimpleXMLElement Object
    (
    [0] => text1
    )
    SimpleXMLElement Object
    (
    [0] => text1
    )
    SimpleXMLElement Object
    (
    [0] => text1
    )


    Actual result:
    --------------
    SimpleXMLElement Object
    (
    [0] => text1
    )
    SimpleXMLElement Object
    (
    [0] => text1
    )
    SimpleXMLElement Object
    (
    [level2a] => text1
    [level2b] => text2
    )

    --
    Edit bug report at [url]http://bugs.php.net/?id=39760&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=39760&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=39760&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=39760&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=39760&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=39760&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=39760&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=39760&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=39760&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=39760&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=39760&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=39760&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=39760&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=39760&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=39760&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=39760&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=39760&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=39760&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=39760&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=39760&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=39760&r=mysqlcfg[/url]
    saschagros at bluewin dot ch Guest

  2. Similar Questions and Discussions

    1. #38406 [Asn->Csd]: PHP crashes when manipulating with SimpleXML object
      ID: 38406 Updated by: tony2001@php.net Reported By: zizka at seznam dot cz -Status: Assigned +Status: ...
    2. #38406 [NoF->Asn]: PHP crashes when manipulating with SimpleXML object
      ID: 38406 Updated by: tony2001@php.net Reported By: zizka at seznam dot cz -Status: No Feedback +Status: ...
    3. #39760 [Opn->Asn]: cloning fails on nested SimpleXML-Object
      ID: 39760 Updated by: tony2001@php.net Reported By: saschagros at bluewin dot ch -Status: Open +Status: ...
    4. #24957 [NEW]: simplexml: var_dump of object segfaults
      From: tater at potatoe dot com Operating system: OS X 10.2 PHP version: 5CVS-2003-08-05 (dev) PHP Bug Type: XML related Bug...
    5. [PHP-DEV] Object cloning
      If I understand correctly the idea is that you will be able to call=20 zend_objects_clone_members() from your clone implementation? If so, I think=...
  3. #2

    Default #39760 [Asn->Csd]: cloning fails on nested SimpleXML-Object

    ID: 39760
    Updated by: [email]rrichards@php.net[/email]
    Reported By: saschagros at bluewin dot ch
    -Status: Assigned
    +Status: Closed
    Bug Type: SimpleXML related
    Operating System: Windows/Linux
    PHP Version: 5.2.0
    Assigned To: helly
    New Comment:

    This bug has been fixed in CVS.

    Snapshots of the sources are packaged every three hours; this change
    will be in the next snapshot. You can grab the snapshot at
    [url]http://snaps.php.net/[/url].

    Thank you for the report, and for helping us make PHP better.




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

    [2006-12-06 22:20:13] saschagros at bluewin dot ch

    Description:
    ------------
    "clone $simpleXML->subElement1->subElement2" does not work as
    excepted.

    It does not return a clone of itself but a clone of it's parent.

    Tested on:
    Windows with PHP 5.2.0
    Linux with PHP 5.2.0
    Linux with PHP 5.0.4

    Reproduce code:
    ---------------
    $xml = '<?xml version="1.0" ?>
    <test>
    <level1>
    <level2a>text1</level2a>
    <level2b>text2</level2b>
    </level1>
    </test>';
    $test = simplexml_load_string($xml);

    print_r($test->level1->level2a);

    $test2 = clone $test;
    print_r($test2->level1->level2a);

    $test3 = clone $test->level1->level2a;
    print_r($test3);

    Expected result:
    ----------------
    SimpleXMLElement Object
    (
    [0] => text1
    )
    SimpleXMLElement Object
    (
    [0] => text1
    )
    SimpleXMLElement Object
    (
    [0] => text1
    )


    Actual result:
    --------------
    SimpleXMLElement Object
    (
    [0] => text1
    )
    SimpleXMLElement Object
    (
    [0] => text1
    )
    SimpleXMLElement Object
    (
    [level2a] => text1
    [level2b] => text2
    )


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39760&edit=1[/url]
    rrichards@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139