php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53289 about __destruct
Submitted: 2010-11-10 09:25 UTC Modified: 2012-10-13 18:50 UTC
From: asersz at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.14 OS: Windows 7
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: asersz at gmail dot com
New email:
PHP Version: OS:

 

 [2010-11-10 09:25 UTC] asersz at gmail dot com
Description:
------------
I am not good at english.. 

Read the following code ..

An error occurs when you run it..
(there will be white-screen in my codes.)



Chinese :
如果你能看懂中文.那最好不过了. 上面的代码我认为__destruct被继承之后, 会导致下面两个类的对象在释放时出现无法找到static $childs的错误. 但是在我的代码里面他确实没有出现这个错误, 反而运行了很久之后出现了白屏. 看上去很像一个死循环.


Test script:
---------------
error_reporting(E_ALL);
ini_set('display_errors', 'on');

abstract class Father {
   private static $childs = array();

   public static function getChild( $child ) {
       if (!array_key_exists("$child", self::$childs)) {
           self::$childs["$child"] = new $child;
       }
       return self::$childs["$child"];
   }

   public function __destruct() {
       foreach (self::$childs as $i => $child) {
            self::$childs[$i] = $child = null;
       }
   }
}

class Child1 extends Father {}
class Child2 extends Father {}

$child1 = Father::getChild('Child1');
$child2 = Father::getChild('Child2');


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-10 23:37 UTC] felipe@php.net
-Status: Open +Status: Feedback -Package: Unknown/Other Function +Package: Scripting Engine problem
 [2010-11-10 23:37 UTC] felipe@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

I can't reproduce any problem with this test script.
 [2012-03-29 15:16 UTC] php dot net at doppy dot nl
I'm unable to reproduce any error's or a white screen.
Code looks fine, although it is a bit of a strange construction.

Recommend closing this bug as "not a bug" as it has been open for 1,5 years now.
 [2012-10-13 18:50 UTC] reeze@php.net
@see http://3v4l.org/QJMph

在所有的版本中都表现正常。。你的描述有点不清楚。这段代码本来就不会有什么输出。
我先关闭了,如果有问题你再reopen吧。

I can't reproduce it, seems not a but,
Closed for now, if you have any issues, please reopen it.
 [2012-10-13 18:50 UTC] reeze@php.net
-Status: Feedback +Status: Not a bug
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 17:01:30 2025 UTC