ID:               25975
 Updated by:       [EMAIL PROTECTED]
 Reported By:      reiersol at online dot no
 Status:           Closed
 Bug Type:         Zend Engine 2 problem
 Operating System: Linux RedHat 9.0
 PHP Version:      5CVS
 New Comment:

Works for me too, just as in your "Expected result".


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

[2004-01-22 03:36:38] reiersol at online dot no

In response to cunha17 at uol dot com dot br:

As far as I can tell, nothing has happened since my November 10
submission. The examples I've given already *should* be more than
sufficient. Perhaps it would be helpful
if you double-check this. To make it really easy, here's a
PHPUnit test to run. Both tests should pass. In PHP 5 beta 1, the
testReplaceObject passes, the other one fails. In the versions after
the dubious fix (including today's CVS version), it's reversed.

require_once 'PHPUnit.php';
class Bar { var $value = 0; }
class Foo {
    var $v1;
    var $v2;
    function Foo() {
        $this->v1 = new Bar;
        $this->v2 = $this->v1;
    }
}

class ReferenceTest extends  PHPUnit_TestCase {

    function testChangeObject() {
        $g = unserialize(serialize(new Foo));
        $g->v2->value = 42;
        $this->assertEquals(42,$g->v1->value);
    }
    function testReplaceObject() {
        $g = unserialize(serialize(new Foo));
        $g->v2 = 42;
        $this->assertTrue($g->v1 instanceof Bar);
    }
}

$suite = new PHPUnit_TestSuite();
$suite->addTestSuite('ReferenceTest');
$result = PHPUnit::run($suite);
echo $result->toString();

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

[2004-01-21 20:16:26] cunha17 at uol dot com dot br

If it's not fixed, please don't give up !
Serialization/Deserialization should work transparently in the same
script or using sessions !!!
Just provide a simple script with the actual and expected results...

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

[2004-01-19 05:23:13] reiersol at online dot no

For the record: I don't think this bug has been fixed, and I think it's
a very serious one, but I'm giving up.

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

[2004-01-11 11:00:25] [EMAIL PROTECTED]

Seems to be fixed now.


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

[2003-12-04 09:52:38] reiersol at online dot no

OK. Here is an example using sessions. Exactly the same thing happens.


<?php
class Bar { public $value = 0; }
class Foo {
    public $v1;
    public $v2;
    function Foo() {
        $this->v1 = new Bar;
        $this->v2 = $this->v1;
    }
}
session_start();

if (isset($_SESSION['g'])) {
    //Try these two one at a time to see the different behaviors:
//    $_SESSION['g']->v2 = "I'm no longer an object";
    $_SESSION['g']->v2->value = 42;
} else {
    $_SESSION['g'] = new Foo;
}
?>
<pre>
<?php 
var_dump($_SESSION['g']);
?>
</pre>

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/25975

-- 
Edit this bug report at http://bugs.php.net/?id=25975&edit=1

Reply via email to