#36268 [Opn->Asn]: Object destructors called even after fatal errors

From: Date: Fri, 03 Feb 2006 07:10:12 +0000
Subject: #36268 [Opn->Asn]: Object destructors called even after fatal errors
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-92865@lists.php.net to get a copy of this message
ID: 36268 Updated by: dmitry@php.net Reported By: hartmut@php.net -Status: Open +Status: Assigned Bug Type: Scripting Engine problem Operating System: linux PHP Version: 5.1.2 -Assigned To: +Assigned To: dmitry Previous Comments: ------------------------------------------------------------------------ [2006-02-02 21:44:19] hartmut@php.net Description: ------------ I just ran into this in CodeGen_PECL, wondering why the script terminated half-way without giving any message, a stripped down reproducing example is added below. Basicly the problem was that a fatal error occuerd (which can't be caught by an error handler) but my output buffer redirection code still kicked in, so swallowing the error message from the still active output buffer its rather strange that i could implement an error handler for E_FATAL errors using destructors whereas error_handler() and register_shutdown_function() can't be used for this Reproduce code: --------------- <?php class ob { private $filename; function __construct($filename) { $this->filename = $filename; ob_start(); } function __destruct() { file_put_contents($this->filename, ob_get_clean()); } } $ob = new ob("ob.txt"); foo::bar(); ?> Expected result: ---------------- the error message "Fatal error: Class 'foo' not found in /home/hartmut/new/ob.php on line 22" shown on the console after calling the script Actual result: -------------- the error message "Fatal error: Class 'foo' not found in /home/hartmut/new/ob.php on line 22" goes to the "ob.txt" file, not the console, when calling this using CLI, the destructor is obviously executed *after* error handling ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36268&edit=1

« previous php.bugs (#92865) next »