Bug #18437: Return value from custom error handler passed back to calling script

From: Date: Fri, 19 Jul 2002 15:50:15 +0000
Subject: Bug #18437: Return value from custom error handler passed back to calling script
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14636@lists.php.net to get a copy of this message
From: duncan@emarketeers.com Operating system: Linux PHP version: 4.2.1 PHP Bug Type: Scripting Engine problem Bug description: Return value from custom error handler passed back to calling script If you set an error handler which returns rather than dying, then the return value of the handler is passed back to the script in place of the expected value iff the statement which raised the error is followed by a function call. Additionally, execution of the remainder of the statement is aborted. This means that e.g. if you reference an unset variable as part of an expression which contains function calls, the expression will evaluate to the return value of the error handler, which is NOT the behaviour if you have not got an error handler installed. i.e. the following will print This fails: --ERROR-- <br> But this works: some text <br> <? function myErrorHandler ($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_USER_ERROR: { echo "A fatal error occurred"; exit; } default : { } } return "--ERROR--"; } define (FATAL,E_USER_ERROR); define (ERROR,E_USER_WARNING); define (WARNING,E_USER_NOTICE); // set the error reporting level for this script error_reporting (FATAL | ERROR | WARNING); set_error_handler("myErrorHandler"); $c = "some text"; $a = $b . trim($c); echo "This fails: $a <br>"; $a = $b . $c; echo "But this works: $a <br>\n"; ?> My config line was: ./configure --with-xslt-sablot --enable-xslt --with-mysql --enable-mailparse --enable-mbstring -- Edit bug report at http://bugs.php.net/?id=18437&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=18437&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=18437&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=18437&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=18437&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=18437&r=support Expected behavior: http://bugs.php.net/fix.php?id=18437&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=18437&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=18437&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=18437&r=globals

« previous php.bugs (#14636) next »