Bug #75955 [Opn->Fbk]: cli and php-fpm assert Behave Differently

From: Date: Thu, 19 Aug 2021 12:50:32 +0000
Subject: Bug #75955 [Opn->Fbk]: cli and php-fpm assert Behave Differently
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235953@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75955&edit=1 ID: 75955 Updated by: cmb@php.net Reported by: xmlscript at gmail dot com Summary: cli and php-fpm assert Behave Differently -Status: Open +Status: Feedback Type: Bug Package: Scripting Engine problem Operating System: Fedora 27 PHP Version: 7.2.2 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Does this still happen with any of the actively supported PHP versions[1]? [1] <https://www.php.net/supported-versions.php> Previous Comments: ------------------------------------------------------------------------ [2018-06-22 17:03:03] nikic@php.net I wasn't able to reproduce this issue against the built-in server. I also tried with and without opcache, as that's a typical cli/server difference. ------------------------------------------------------------------------ [2018-02-13 05:55:06] xmlscript at gmail dot com Description: ------------ I want to get assertion code "assert(sleep(3))", but return "Assertion failed" or $exception->getMessage() === "". =========================================================== php -r 'assert_options(ASSERT_ACTIVE,true);assert(sleep(3));' PHP Warning: assert(): **assert(sleep(3))** failed in Command line code on line 1 PHP Stack trace: PHP 1. {main}() Command line code:0 PHP 2. assert() Command line code:1 Warning: assert(): **assert(sleep(3))** failed in Command line code on line 1 Call Stack: 0.0001 406984 1. {main}() Command line code:0 3.0001 407360 2. assert() Command line code:1 =========================================================== script file "test.php": <?php echo PHP_SAPI,PHP_EOL; assert_options(ASSERT_ACTIVE,true); assert(sleep(3)); ?> =========================================================== lynx localhost/test.php fpm-fcgi ( ! ) Warning: assert(): **Assertion failed** in /path/to/test.php on line 4 Call Stack # Time Memory Function Location 1 0.0002 406992 {main}( ) .../exception.php:0 2 3.0003 407368 assert ( ) .../exception.php:4 =========================================================== php test.php cli PHP Warning: assert(): **Assertion failed** in /path/to/test.php on line 4 PHP Stack trace: PHP 1. {main}() /path/to/test.php:0 PHP 2. assert() /path/to/test.php:4 Warning: assert(): Assertion failed in /path/to/test.php on line 4 Call Stack: 0.0001 407896 1. {main}() /path/to/test.php:0 3.0002 408304 2. assert() /path/to/test.php:4 =========================================================== php -r 'assert_options(ASSERT_ACTIVE,true);assert_options(ASSERT_EXCEPTION,true);assert(sleep(3));' PHP Fatal error: Uncaught AssertionError: **assert(sleep(3))** in Command line code:1 Stack trace: #0 Command line code(1): assert(0, 'assert(sleep(3)...') #1 {main} thrown in Command line code on line 1 Fatal error: Uncaught AssertionError: **assert(sleep(3))** in Command line code on line 1 AssertionError: assert(sleep(3)) in Command line code on line 1 Call Stack: 0.0000 407384 1. {main}() Command line code:0 3.0001 407760 2. assert() Command line code:1 =========================================================== script file "test_with_exception.php": <?php echo PHP_SAPI,PHP_EOL; assert_options(ASSERT_ACTIVE,true); assert_options(ASSERT_EXCEPTION,true); assert(sleep(3)); ?> =========================================================== lynx localhost/test_with_exception.php fpm-fcgi ( ! ) Fatal error: Uncaught AssertionError in /path/to/test_with_exception.php on line 5 ( ! ) AssertionError: in /path/to/test_with_exception.php on line 5 Call Stack # Time Memory Function Location 1 0.0001 407496 {main}( ) .../test_with_exception.php:0 2 3.0002 407872 assert ( ) .../test_with_exception.php:5 =========================================================== php test_with_exception.php cli PHP Fatal error: Uncaught AssertionError in /path/to/test_with_exception.php:5 Stack trace: #0 /path/to/test_with_exception.php(5): assert(0) #1 {main} thrown in /path/to/test_with_exception.php on line 5 Fatal error: Uncaught AssertionError in /path/to/test_with_exception.php on line 5 AssertionError: in /path/to/test_with_exception.php on line 5 Call Stack: 0.0001 408408 1. {main}() /var/www/vhost/e/exception.php:0 3.0002 408816 2. assert() /var/www/vhost/e/exception.php:5 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75955&edit=1

« previous php.bugs (#235953) next »