php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #71364 restore_error_handler() should return the actual callable
Submitted: 2016-01-14 03:01 UTC Modified: -
From: hujuice at inservibile dot org Assigned:
Status: Open Package: Unknown/Other Function
PHP Version: 5.6Git-2016-01-14 (snap) OS: Linux
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: hujuice at inservibile dot org
New email:
PHP Version: OS:

 

 [2016-01-14 03:01 UTC] hujuice at inservibile dot org
Description:
------------
restore_error_handler() returns always true, no info.
But in complex situations where included files could add other handlers, there's no way to be sure that the restored handler is the wanted one.

This doubt could be prevented if restore_error_handler() would return the actual callable or null if at the end of the stack.


Test script:
---------------
file1.php
=========
<?php
set_error_handler('someFunct');
include 'file2.php';
restore_error_handler(); // Not enough!

file2.php
=========
<?php
set_error_handler('anotherFunct');

Expected result:
----------------
NOT CORRECT! It could be an useful feature

file1.php
=========
<?php
$prev = set_error_handler('someFunct');
include 'file2.php';
do {
   $actual = restore_error_handler(); // Run twice
} while ($actual != $prev);

file2.php
=========
<?php
set_error_handler('anotherFunct');


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 13:01:29 2024 UTC