Bug #77981 [NEW]: Missing very important variable name in error logging (core)

From: Date: Tue, 07 May 2019 11:33:23 +0000
Subject: Bug #77981 [NEW]: Missing very important variable name in error logging (core)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220733@lists.php.net to get a copy of this message
From: forkik at gmail dot com Operating system: PHP version: Irrelevant Package: Reproducible crash Bug Type: Bug Bug description:Missing very important variable name in error logging (core) Description: ------------ Very important to know (from log) and to log in which variable (name of the variable) error like "NOTICE (Undefined offset: 1)" occurred! Still it is NOT POSSIBLE! This is important when one of these situations occur (the more situations occurred the more difficult to detect the exact variable (name)): 1. code changes rapidly (so error line can even mislead without variable name); 2. variables data is from database (and database changes rapidly in big database so it is impossible to detect in which variable name); 3. there are multiple variables in the same line. Test script: --------------- <?php $A = [1 => '']; $B = [1 => '']; $X_variable_name = []; set_error_handler('log_handler'); function log_handler ( $errno, $errstr, $errfile, $errline, $errcontext ) { $bt = debug_backtrace(); //print_r($bt); $bt0 = (isset($bt[0]) && isset($bt[0]['file']) ? basename(dirname($bt[0]['file'])).'/'.basename($bt[0]['file']).':'.$bt[0]['line'] : ''); $bt1 = (isset($bt[1]) ? basename(dirname($bt[1]['file'])).'/'.basename($bt[1]['file']).':'.$bt[1]['line'] : ''); $bt2 = (isset($bt[2]) ? basename(dirname($bt[2]['file'])).'/'.basename($bt[2]['file']).':'.$bt[2]['line'] : ''); $errorType = [E_ERROR => 'ERROR',E_WARNING => 'WARNING',E_PARSE => 'PARSING ERROR',E_NOTICE => 'NOTICE',E_CORE_ERROR => 'CORE ERROR',E_CORE_WARNING => 'CORE WARNING',E_COMPILE_ERROR => 'COMPILE ERROR',E_COMPILE_WARNING => 'COMPILE WARNING',E_USER_ERROR => 'USER ERROR',E_USER_WARNING => 'USER WARNING',E_USER_NOTICE => 'USER NOTICE',E_STRICT => 'STRICT NOTICE',E_RECOVERABLE_ERROR => 'RECOVERABLE ERROR']; echo date("y-m-d H:i:s").' '.$errorType[$errno]." ($errstr) ".$errfile.":$errline "./*print_r($errcontext, true).*/' '.$bt0.' 1:'.$bt1.' 2:'.$bt2."\n"; //debug_print_backtrace(); } echo $A[1].$B[1].$X_variable_name[1]; Expected result: ---------------- 19-05-07 14:07:06 NOTICE (Undefined offset: 1 in variable: X_variable_name) /home/tests/php/error_log.php:65 php/error_log.php:65 1: 2: Actual result: -------------- 19-05-07 14:07:06 NOTICE (Undefined offset: 1) /home/tests/php/error_log.php:65 php/error_log.php:65 1: 2: -- Edit bug report at https://bugs.php.net/bug.php?id=77981&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77981&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77981&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77981&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77981&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77981&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77981&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77981&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77981&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77981&r=support Expected behavior: https://bugs.php.net/fix.php?id=77981&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77981&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77981&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77981&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77981&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77981&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77981&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77981&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77981&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77981&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77981&r=mysqlcfg

« previous php.bugs (#220733) next »