php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34329 The bug #31675 is present in 5.04 and 5.1
Submitted: 2005-09-01 16:06 UTC Modified: 2005-09-01 17:47 UTC
From: marcos dot neves at gmail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.1.0RC1 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marcos dot neves at gmail dot com
New email:
PHP Version: OS:

 

 [2005-09-01 16:06 UTC] marcos dot neves at gmail dot com
Description:
------------
The bug #31675 is closed and says its fixed,
but the problem persist in 5.04 and 5.1.

Reproduce code:
---------------
<?
function error_handler1() {
	echo "[".__FUNCTION__."]";
}

function error_handler2() {
	echo "[".__FUNCTION__."]";
	restore_error_handler();// does not restore
}

set_error_handler('error_handler1');
set_error_handler('error_handler2');

echo foo;
?>

Expected result:
----------------
[error_handler1]foo

Actual result:
--------------
[error_handler2]foo

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-01 16:18 UTC] sniper@php.net
Maybe you should read how the "bug" was resolved? It wasn't really bug in PHP itself but just missing documentation.

 [2005-09-01 16:51 UTC] marcos dot neves at gmail dot com
Sorry, I did more tests and it's still no right.
The documentation says: "Calling restore_error_handler() from the error_handler function is ignored."
This is bugged for 5.0.4 and is not true for 5.1.0RC1

The follow code works as I expect in 5.1.0RC1 on windows.
But on 5.0.4 restore_error_handler is ignored inside error_handler, but calling restore_error_handler outside, will exec twice, as if the restore_error_handler was pushed on a stack.

<pre>
<?

function error_handler1() {
	echo "\n[".__FUNCTION__."]\n";
}

function error_handler2() {
	echo "\n[".__FUNCTION__."]\n";
}

function error_handler3() {
	echo "\n[".__FUNCTION__."]\n";
//	restore_error_handler();
}

function error_handler4() {
	echo "\n[".__FUNCTION__."]\n";
	restore_error_handler();
}

set_error_handler('error_handler1');
set_error_handler('error_handler2');
set_error_handler('error_handler3');
set_error_handler('error_handler4');

echo foo;
echo bar;

restore_error_handler();

echo test;

?>

RESULT FOR 5.0.4
[error_handler4]
foo
[error_handler4]
bar
[error_handler1]
test

if the restore_error_handler is really ignored inside error handler, the result should be:
[error_handler4]
foo
[error_handler4]
bar
[error_handler3]
test

RESULT FOR 5.1.0RC1
[error_handler4]
foo
[error_handler3]
bar
[error_handler1]
test

it seens that restore_error_handler is not ignored inside handler on 5.1.0RC1
 [2005-09-01 17:47 UTC] sniper@php.net
If it's fixed in 5.1, it's fixed. If it's not fixed in 5.0.4, too bad.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 21:01:30 2024 UTC