rfc:error_handler_callback_parameters_passed_by_reference

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:error_handler_callback_parameters_passed_by_reference [2015/02/13 00:11] – updated open issues thbleyrfc:error_handler_callback_parameters_passed_by_reference [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== PHP RFC: Allow error_handler callback parameters to be passed by reference ====== ====== PHP RFC: Allow error_handler callback parameters to be passed by reference ======
-  * Version: 0.1 +  * Version: 0.2 
-  * Date: 2015-01-26 (initial draft)+  * Date: 2015-02-28
   * Authors: Reeze Xia <reeze@php.net>, Thomas Bley <mails@thomasbley.de>   * Authors: Reeze Xia <reeze@php.net>, Thomas Bley <mails@thomasbley.de>
-  * Status: Draft+  * Status: Declined
   * First Published at: http://wiki.php.net/rfc/error_handler_callback_parameters_passed_by_reference   * First Published at: http://wiki.php.net/rfc/error_handler_callback_parameters_passed_by_reference
  
Line 172: Line 172:
 ==== Performance ==== ==== Performance ====
  
-TODO+Performance is not affected in normal code execution. In case of an error that can be handled in user-space, we need to copy the referenced variables back to their origins.
  
 ===== Open Issues ===== ===== Open Issues =====
Line 204: Line 204:
 </code> </code>
  
-This issue is not related to this rfc and handled as separately in: https://bugs.php.net/bug.php?id=68963+This issue is not related to this rfc and handled separately on https://bugs.php.net/bug.php?id=68963
  
 2. Callback parameter errstr can be changed to an empty string, example: 2. Callback parameter errstr can be changed to an empty string, example:
Line 252: Line 252:
 Possible, but may not come into major distributions if they stick to special minor releases Possible, but may not come into major distributions if they stick to special minor releases
 (e.g. Ubuntu 14.04: 5.5.9, Ubuntu 14.10: 5.5.12, latest: 5.5.21) (e.g. Ubuntu 14.04: 5.5.9, Ubuntu 14.10: 5.5.12, latest: 5.5.21)
 +
 +5. Why can't you just use the error_log() function to write the exact message you want?
 +
 +In the future, set_error_handler() might be changed to be called multiple times with different custom error handlers, similar to how register_shutdown_function() and spl_autoload_register() act on multiple calls.
 +Having a chain of error handlers appending data to $errstr makes it difficult to use error_log(), because this is a one-time operation. Also, error_log() has the ability to override the "error_log" property from
 +php.ini, which might not be the desired behaviour. For completeness, error_log() currently has no parameters for $errno, $line and
 +$file, so an example would look like this:
 +
 +<file php test_error_log.php>
 +function myErrorHandler($errno, $errstr, $errfile, $errline) {
 +  switch($errno){
 +    case E_WARNING:           $errnoStr='Warning'; break;
 +    case E_NOTICE:            $errnoStr='Notice'; break;
 +    case E_STRICT:            $errnoStr='Strict'; break;
 +    case E_RECOVERABLE_ERROR: $errnoStr='Recoverable Error'; break;
 +    case E_DEPRECATED:        $errnoStr='Deprecated'; break;
 +    case E_USER_ERROR:        $errnoStr='User Error'; break;
 +    case E_USER_WARNING:      $errnoStr='User Warning'; break;
 +    case E_USER_NOTICE:       $errnoStr='User Notice'; break;
 +    case E_USER_DEPRECATED:   $errnoStr='User Deprecated'; break;
 +  } 
 +  if (!empty($_SESSION['username'])) {
 +    $errstr .= ', username: '.$_SESSION['username'];
 +  }
 +  error_log('PHP '.$errnoStr.':  '.$errstr.' in '.$errfile.' on line '.$errline);
 +  return true;
 +}
 +</file>
  
 ===== Future Scope ===== ===== Future Scope =====
Line 262: Line 290:
 </code> </code>
  
-===== Proposed Voting Choices ===== +===== Vote =====
- +
-This RFC requires a 50%+1 majority.  +
- +
-There will be three options: +
- +
-1. Allow $errno, $errstr, $errfile, $fileno parameter to be passed by reference +
- +
-2. Allow $errstr parameter been passed by reference+
  
-3. NoAllow none of the parameter be a reference parameter+This RFC requires a 50%+1 majoritymeaning the first two choices count as Yes, the third choice counts as No. Voting started on 2015-02-13 and will end on 2015-02-27.
  
 +<doodle title="Allow error_handler callback parameters to be passed by reference" auth="thbley" voteType="single" closed="true">
 +   * Allow $errstr parameter to be passed by reference
 +   * Allow $errno, $errstr, $errfile, $fileno parameter to be passed by reference
 +   * No, Allow none of the parameter be a reference parameter
 +</doodle>
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
  
-Currently implemented on https://github.com/php/php-src/pull/1018+Currently implemented on https://github.com/php/php-src/pull/1018\\ 
 PR is against master and includes the first four callback parameters to be passed by reference. PR is against master and includes the first four callback parameters to be passed by reference.
 +The PR will be updated to correspond vote if any one of the accepted.
  
 I've used to build on Ubuntu 14.04: I've used to build on Ubuntu 14.04:
Line 294: Line 320:
 ===== References ===== ===== References =====
  
-Discussion on php-internals: http://marc.info/?t=142181539200002&r=1&w=2 +  * Discussion on php-internals: http://marc.info/?t=142181539200002&r=1&w=2 
-Discussion on Github: https://github.com/php/php-src/pull/1018+  Discussion on Github: https://github.com/php/php-src/pull/1018
  
 ===== Rejected Features ===== ===== Rejected Features =====
Line 303: Line 329:
 ===== Changelog ===== ===== Changelog =====
  
-v0.2 - updated open issues (thbley) +  * v0.2 - updated open issues (thbley) 
-v0.1 - Initial draft (thbley)+  v0.1 - Initial draft (thbley)
rfc/error_handler_callback_parameters_passed_by_reference.1423786318.txt.gz · Last modified: 2017/09/22 13:28 (external edit)