|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-09-08 20:00 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 19:00:01 2025 UTC |
Description: ------------ in the php_error_cb function the spprintf function is called as well as other code to allocate an error message even if this error message is never displayed due to logging levels or output settings. (ie: error_reporting = E_ALL | ~E_NOTICE would cause all E_NOTICE messages to be allocated but not displayed). This patch will short circuit the function call in these cases... Index: main/main.c =================================================================== RCS file: /repository/php-src/main/main.c,v retrieving revision 1.640.2.23.2.13 diff -u -r1.640.2.23.2.13 main.c --- main/main.c 17 Aug 2006 13:43:08 -0000 1.640.2.23.2.13 +++ main/main.c 6 Sep 2006 18:07:35 -0000 @@ -657,6 +657,14 @@ int buffer_len, display; TSRMLS_FETCH(); + /* Only go through this code if we are going to do something worth while... */ + if ( PG(error_handling) == EH_NORMAL + && ( !(EG(error_reporting) & type) || !( PG(log_errors) || PG(display_errors) || (!module_initialized) ) ) + && !( type & (E_ERROR | E_CORE | E_COMPILE_ERROR | E_USER_ERROR | E_PARSE | E_RECOVERABLE_ERROR) ) + ) { + return; + } + buffer_len = vspprintf(&buffer, PG(log_errors_max_len), format, args); /* check for repeated errors to be ignored */ Reproduce code: --------------- Set error_reporting to include E_NOTICE, use a test file like: <?php echo $foo; // Produce E_NOTICE ?> Expected result: ---------------- gdb trace shows the call into vpprintf... Breakpoint 1, php_error_cb (type=8, error_filename=0x78def0 "/Users/shire/www/error.php", error_lineno=3, format=0x2443f8 "Undefined variable: %s", args=0xbfffec58 "??x") at /Users/shire/data/phpcvs-5.2/main/main.c:661 661 if ( PG(error_handling) == EH_NORMAL (gdb) n 668 buffer_len = vspprintf(&buffer, PG(log_errors_max_len), format, args); Actual result: -------------- With the patch we skip this step when error_reporting does not include E_NOTICE... Breakpoint 1, php_error_cb (type=8, error_filename=0x78def0 "/Users/shire/www/error.php", error_lineno=3, format=0x2443f8 "Undefined variable: %s", args=0xbfffec58 "??x") at /Users/shire/data/phpcvs-5.2/main/main.c:661 661 if ( PG(error_handling) == EH_NORMAL (gdb) n 867 } (gdb) n zend_error (type=8, format=0x2443f8 "Undefined variable: %s") at /Users/shire/data/phpcvs-5.2/Zend/zend.c:942 942 if (!EG(user_error_handler)