Skip to content

Allow resetting the error handler #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nikic
Copy link
Member

@nikic nikic commented Mar 23, 2012

This allows the error handler to be reset using set_error_handler(null). As the code suggests this behavior was already previously intended, but the callback check was done too strictly.

See also bug https://bugs.php.net/bug.php?id=60738.

PS: I replaced the !zend_is_true with a strict null check to be consistent with the behavior of set_exception_handler.

This allows the error handler to be reset using set_error_handler(null).
As the code suggests this behavior was already previously intended, but
the callback check was done too strictly.
@laruence
Copy link
Member

Hi, I attached another fix, this will save one alloc/free pair, and also save one (IS_NULL == Z_TYPE_P(error_handler).
here it is:https://bugs.php.net/patch-display.php?bug_id=60738&patch=bug60738.patch&revision=latest

Nikic, if you have no objection, I will commit the patch. and later, also improve the set_exception_handler.

thanks

@laruence
Copy link
Member

since I will offline for maybe two days, I commited, if you have any question, plz write me :) thanks

@php-pulls
Copy link

Comment on behalf of laruence at php.net:

implemented

@php-pulls
Copy link

Comment on behalf of laruence at php.net:

seems I can not close this pull request via qa.php.net

@php-pulls php-pulls closed this Mar 24, 2012
@nikic
Copy link
Member Author

nikic commented Mar 24, 2012

@laruence I wanted to submit another PR which makes set_error_handler(null) return the previous error handler instead of just true. That's why I left the code intact, as it was easier to implement with the old code structure.

@smalyshev
Copy link
Contributor

set_error_handler(null) should return previous one just like all others. If it's not so with new patch, should be fixed.

@laruence
Copy link
Member

On Sat, Mar 24, 2012 at 4:48 PM, Stanislav Malyshev
[email protected]
wrote:

set_error_handler(null) should return previous one just like all others. If it's not so with new patch, should be fixed.
Hi:
in the manual of set_exception_handler says:
" Returns the name of the previously defined exception handler, or
NULL on error. If no previous handler was defined, NULL is also
returned. If NULL is passed, resetting the handler to its default
state, TRUE is returned. "

thanks


Reply to this email directly or view it on GitHub:
#18 (comment)

惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com

@laruence
Copy link
Member

On Sat, Mar 24, 2012 at 4:21 PM, nikic
[email protected]
wrote:

@laruence I wanted to submit another PR which makes set_error_handler(null) return the previous error handler instead of just true. That's why I left the code intact, as it was easier to implement with the old code structure.

I don't think that should be done, since set_exception_handler return
TRUE when passing NULL to it.

thanks


Reply to this email directly or view it on GitHub:
#18 (comment)

惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com

@laruence
Copy link
Member

On Sat, Mar 24, 2012 at 4:21 PM, nikic
[email protected]
wrote:

@laruence I wanted to submit another PR which makes set_error_handler(null) return the previous error handler instead of just true. That's why I left the code intact, as it was easier to implement with the old code structure.

And, I really don't think your new PR should relay on a code
structure, so, just file your new FR. :)

thanks


Reply to this email directly or view it on GitHub:
#18 (comment)

惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com

@smalyshev
Copy link
Contributor

I have no idea why set_exception_handler() returns true in this case, makes very little sense.

@php-pulls
Copy link

On Sat, Mar 24, 2012 at 5:50 PM, Stanislav Malyshev
[email protected]
wrote:

I have no idea why set_exception_handler() returns true in this case, makes very little sense.
So, that is another issue.

In this fix, I made them consistent.

if we decide to change the return value, then set_exception_handler
should also be change.

thanks


Reply to this email directly or view it on GitHub:
#18 (comment)

Git Pull Requests Mailing List (https://github.com/php)
To unsubscribe, visit: http://www.php.net/unsub.php

Laruence  Xinchen Hui
http://www.laruence.com/

@smalyshev
Copy link
Contributor

This is why changes like this should be done in a branch, announced on the list and discussed, not put into stable branch first and discussed later.

@laruence
Copy link
Member

On Sat, Mar 24, 2012 at 6:02 PM, Stanislav Malyshev
[email protected]
wrote:

This is why changes like this should be done in a branch, announced on the list and discussed, not put into stable branch first and discussed later.

what change? you mean "allow NULL value pass to set_error_handler"?

I think this is a little change, so I committed it, but yeah, if
there comes objections, I can revert it. :)

thanks


Reply to this email directly or view it on GitHub:
#18 (comment)

惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com

@smalyshev
Copy link
Contributor

first, it's not a little change, it changes a lot in this function. Second, I'm not sure these functions should work this way, and I see no reason to rush with it without discussion. Please revert it for from 5.4, put it into a feature branch and let's see what's the best way to take there.

@laruence
Copy link
Member

On Sat, Mar 24, 2012 at 6:11 PM, Stanislav Malyshev
[email protected]
wrote:

first, it's not a little change, it changes a lot in this function. Second, I'm not sure these functions should work this way, and I see no reason to rush with it without discussion. Please revert it for from 5.4, put it into a feature branch and let's see what's the best way to take there.

okey, how about the previous one: "improve set_exception_handler",
also revert it? it change code but not behavior..

thanks


Reply to this email directly or view it on GitHub:
#18 (comment)

惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com

@nikic
Copy link
Member Author

nikic commented Mar 24, 2012

Sorry for causing all this confusion. I'll create a new PR which will include all changes including the fix for the return value and the memory leak which currently exists in these functions.

@php-pulls
Copy link

Hi:

Reverted. both the two changes, then committed to trunk only .

thanks

On Sat, Mar 24, 2012 at 6:14 PM, Xinchen Hui
[email protected]
wrote:

On Sat, Mar 24, 2012 at 6:11 PM, Stanislav Malyshev
[email protected]
wrote:

first, it's not a little change, it changes a lot in this function. Second, I'm not sure these functions should work this way, and I see no reason to rush with it without discussion. Please revert it for from 5.4, put it into a feature branch and let's see what's the best way to take there.

okey,  how about the previous one: "improve set_exception_handler",
also revert it?  it change code but not behavior..

thanks


Reply to this email directly or view it on GitHub:
#18 (comment)

惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com


Reply to this email directly or view it on GitHub:
#18 (comment)

Git Pull Requests Mailing List (https://github.com/php)
To unsubscribe, visit: http://www.php.net/unsub.php

Laruence  Xinchen Hui
http://www.laruence.com/

@laruence
Copy link
Member

Nikic:

np, it's alright, we always doing commit/revert.. :)

thanks

On Sat, Mar 24, 2012 at 7:43 PM, nikic
[email protected]
wrote:

Sorry for causing all this confusion. I'll create a new PR which will include all changes including the fix for the return value and the memory leak which currently exists in these functions.


Reply to this email directly or view it on GitHub:
#18 (comment)

惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com

php-pulls pushed a commit that referenced this pull request Dec 24, 2013
Errors not displaying in some configurations
php-pulls pushed a commit that referenced this pull request Dec 24, 2013
Errors not displaying in some configurations
php-pulls pushed a commit that referenced this pull request Oct 28, 2014
Errors not displaying in some configurations
ahamid added a commit to ahamid/php-src that referenced this pull request Jun 29, 2019
* PHP-5.6:
  fixed incompatible pointer in phpdbg on win64
  Fixed php#18 Errors not displaying in some configurations
  Fixed php#18 Errors not displaying in some configurations
  update credits headers
  credits file for phpdbg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants