Re: Bug in current Object Model

From: Date: Wed, 13 Feb 2002 18:24:26 +0000
Subject: Re: Bug in current Object Model
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-80022@lists.php.net to get a copy of this message
I don't think it's a bug. This weird behavior is due to the Engine 1 object model (which will be different in Engine 2). At 07:38 PM 2/12/2002 -0600, Jason Greene wrote:
Zeev, Andi It appears that the bug we talked about in private correspondence does not just apply to object overloading. It appears to apply to normal objects as well. Consider the following code: class test {
    var $dummy;
    function do_something() {
         print "Hello\n";
    }
} $obj=new test();
$obj == is_ref=1/refcount=1
debug_zval_dump($obj);
You are passing $obj by value. So inside the debug_zval_dump() it will be is_ref=0/refcount=1 (it will be copied).
$obj->do_something();
Inside do_something it will be is_ref=1/refcount=2
debug_zval_dump($obj);
You are passing $obj by value. So inside the debug_zval_dump() it will be is_ref=0/refcount=1 (it will be copied). Bottom line: Passing it by value makes it duplicate. This is Engine 1. Nothing to do about it. I guess debug_zval_dump() isn't that useful after all :) Andi
This will produce the following output: object(test)(1) refcount(2){ ["dummy"]=> long(1) refcount(2) } Hello object(test)(1) refcount(1){ ["dummy"]=> long(1) refcount(3) } ZEND_SEND_VAR is the opcode that does this in this scenario as well -jason -- Jason T. Greene Internet Software Engineer <jason@inetgurus.net> <jason@php.net> <jason.greene@tdstelecom.com> Use PHP: http://www.php.net


« previous php.dev (#80022) next »