php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54424 failed assert with ASSERT_BAIL exits with return code == 0
Submitted: 2011-03-30 15:04 UTC Modified: 2021-02-15 14:06 UTC
Votes:6
Avg. Score:4.3 ± 0.5
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:4 (66.7%)
From: jakub dot lopuszanski at nasza-klasa dot pl Assigned: cmb (profile)
Status: Wont fix Package: PHP options/info functions
PHP Version: 5.3.6 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-03-30 15:04 UTC] jakub dot lopuszanski at nasza-klasa dot pl
Description:
------------
Failed assertions should be signaled by non-zero return code from the script as they are errors.

Test script:
---------------
$ cat example.php
<?php
assert_options(ASSERT_BAIL,     true);
assert(false);
?>
$ php example.php
PHP Warning:  assert(): Assertion failed in /home/lopuszanski/projects/NK-2/tests/php/example.php on line 3
$ echo $?
0

Expected result:
----------------
echo $? should display some nonzero return code

Actual result:
--------------
0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-15 14:06 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Package: *General Issues +Package: PHP options/info functions -Assigned To: +Assigned To: cmb
 [2021-02-15 14:06 UTC] cmb@php.net
> Failed assertions should be signaled by non-zero return code
> from the script as they are errors.

Right.  However, the usage of assert_options() is discouraged as
of PHP 7.0.0; use assert.exceptions instead, and the
AssertionError, if not caught, will set a non-zero exit status.  I
don't think that fixing the behavior of ASSERT_BAIL would still be
sensible at this point in time.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC