Skip to content

Conversation

reeze
Copy link
Contributor

@reeze reeze commented Mar 3, 2015

In PHP a simple assign expression would raise error, if user use error_get_last() to check they can't guarantee the call site raise the error.

This patch implement a function to clear the error state. There are similar functions like socket_clear_error().

http://php.net/error_get_last
The top voted user contributed note are a tricky way to clear last error.

also there are a lot of apps use the similar hacks.

  1. https://github.com/mathnerd3141/doeqs_new/blob/ba23c478a0c819dc6b2f8f96f9df35d16505eed2/errors.php#L20
  2. https://github.com/benfinke/cargo_plane/blob/4911bc6a91d8345aa62c81fb52c8bed9d216c44e/Splunk/Util.php#L89

Request: https://bugs.php.net/bug.php?id=45235

Clear the last occurred error. Returns false if there hasn't been an error yet. */
PHP_FUNCTION(error_clear_last)
{
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use zend_parse_parameters_none()

@ghost
Copy link

ghost commented Mar 7, 2015

Can one of the admins verify this patch?

@php-pulls php-pulls merged commit 916709c into php:master Mar 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants