From: [EMAIL PROTECTED]
Operating system: linux
PHP version: 5CVS-2004-01-28 (dev)
PHP Bug Type: Zend Engine 2 problem
Bug description: __clone() has problem with the vision. maybe needs glasses? :)
Description:
------------
In the following code __clone() have problems with member variables of
type
object ($this->obj is null). If the comment is removed from the call to
__clone2() in __clone() then __clone2() also has problems with the vision.
On
the other hand __clone2() has no problems when called externally. The
difference between the expected and the actual result is the second call
to print_r()
Reproduce code:
---------------
<?php
class clone_example {
private $pub = 2;
private $obj = NULL;
function clone_example($obj) {
$this->obj = $obj;
}
function __clone() {
print_r($this);
// $this->__clone2();
}
function __clone2() {
print_r($this);
}
}
class fubar {
public $v = array(1,2,3);
}
$fu = new fubar();
$a = new clone_example($fu);
$a->__clone2();
$a->__clone();
$a->__clone2();
?>
Expected result:
----------------
clone_example Object
(
[pub:private] => 2
[obj:private] => fubar Object
(
[v] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
)
)
clone_example Object
(
[pub:private] => 2
[obj:private] => fubar Object
(
[v] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
)
)
clone_example Object
(
[pub:private] => 2
[obj:private] => fubar Object
(
[v] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
)
)
Actual result:
--------------
clone_example Object
(
[pub:private] => 2
[obj:private] => fubar Object
(
[v] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
)
)
clone_example Object
(
[pub:private] => 2
[obj:private] =>
)
clone_example Object
(
[pub:private] => 2
[obj:private] => fubar Object
(
[v] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
)
)
--
Edit bug report at http://bugs.php.net/?id=27074&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27074&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27074&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27074&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27074&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27074&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27074&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27074&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27074&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27074&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27074&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27074&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27074&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27074&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27074&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27074&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27074&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27074&r=float