Bug #75955 [Opn]: cli and php-fpm assert Behave Differently
| From: | nikic@php.net | Date: | Fri, 22 Jun 2018 17:03:04 +0000 |
| Subject: | Bug #75955 [Opn]: cli and php-fpm assert Behave Differently | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215872@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: nikic@php.net
Reported by: xmlscript at gmail dot com
Summary: cli and php-fpm assert Behave Differently
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: Fedora 27
PHP Version: 7.2.2
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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