Bug #80058 [Wfx]: Unparenthesized `a ? b : c ? d : e` does not trigger own error handler

From: Date: Mon, 07 Sep 2020 07:40:43 +0000
Subject: Bug #80058 [Wfx]: Unparenthesized `a ? b : c ? d : e` does not trigger own error handler
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228916@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80058&edit=1 ID: 80058 Updated by: nikic@php.net Reported by: jochem dot blok at fasterforward dot nl Summary: Unparenthesized a ? b : c ? d : e does not trigger own error handler Status: Wont fix Type: Bug Package: Unknown/Other Function Operating System: Ubuntu 20.04 PHP Version: 7.4.10 Block user comment: N Private report: N New Comment: Yes, opcache disables custom error handlers during compilation. I also checked that the opcache.replay_warnings mode in PHP 8 doesn't affect this. It looks like this opcache issue already has a bug report at bug #73665. Previous Comments: ------------------------------------------------------------------------ [2020-09-04 12:38:23] jochem dot blok at fasterforward dot nl This is indeed the case when opcache is disbaled. BUT if you enable opcase the error is not handled by the error handler. Only by the shutdown handler. ------------------------------------------------------------------------ [2020-09-04 10:38:16] nikic@php.net This is a compile-time error, that is triggered before your set_error_handler() call. To catch it, set_error_handler() needs to be called before the file is included. ------------------------------------------------------------------------ [2020-09-04 10:34:59] jochem dot blok at fasterforward dot nl Description: ------------ Error "Unparenthesized a ? b : c ? d : e is deprecated. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e)" does not trigger own error handler. Callingerror_get_last() does return this error. Test script: --------------- function shutdown() { $error = error_get_last(); var_dump($error); } register_shutdown_function('shutdown'); function myErrorHandler($errno, $errstr, $errfile, $errline) { echo "\n\n--------------- ERROR ---------------------\n\n"; echo "\n".'errno = '; print_r($errno); echo "\n".'errstr = '; print_r($errstr); echo "\n".'errfile = '; print_r($errfile); echo "\n".'errline = '; print_r($errline); return true; } set_error_handler("myErrorHandler"); $a = 1; $b = 2; $c = 3; $d = 4; $e = 5; echo $a ? $b : $c ? $d : $e; parse_str ('wrweqr'); Expected result: ---------------- As you can see parse_str is handle by the own error handler. "echo $a ? $b : $c ? $d : $e;" should also be handled. Actual result: -------------- Only parse_str is handled. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80058&edit=1

« previous php.bugs (#228916) next »