php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #71873 Warning:zend.assertions may be completely enabled or disabled only in php.ini
Submitted: 2016-03-21 17:25 UTC Modified: 2016-03-28 06:43 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ildar dot aim at gmail dot com Assigned: krakjoe (profile)
Status: Closed Package: *Configuration Issues
PHP Version: 7.0.4 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ildar dot aim at gmail dot com
New email:
PHP Version: OS:

 

 [2016-03-21 17:25 UTC] ildar dot aim at gmail dot com
Description:
------------
According to 
http://php.net/manual/en/ini.core.php

zend.assertions	 is PHP_INI_ALL

In spite of this fact my script generates php warninig
"Warning: zend.assertions may be completely enabled or disabled only in php.ini"

-------------
My info

aim-server[~/tmp]$ php -i |grep -i assert
zend.assertions => -1 => -1
assert.active => 1 => 1
assert.bail => 0 => 0
assert.callback => no value => no value
assert.exception => 0 => 0
assert.quiet_eval => 0 => 0
assert.warning => 1 => 1
aim-server[~/tmp]$ 
aim-server[~/tmp]$ php -v                
PHP 7.0.4 (cli) (built: Mar  5 2016 09:28:27) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
aim-server[~/tmp]$ 


Test script:
---------------
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('zend.assertions', 1);
var_dump('end');die;


Expected result:
----------------
string(3) "end"


Actual result:
--------------
PHP Warning:  zend.assertions may be completely enabled or disabled only in php.ini in /home/aim/tmp/home.php on line 46
PHP Stack trace:
PHP   1. {main}() /home/aim/tmp/home.php:0
PHP   2. ini_set() /home/aim/tmp/home.php:46

Warning: zend.assertions may be completely enabled or disabled only in php.ini in /home/aim/tmp/home.php on line 46

Call Stack:
    0.0002     399768   1. {main}() /home/aim/tmp/home.php:0
    0.0002     400280   2. ini_set() /home/aim/tmp/home.php:46

/home/aim/tmp/home.php:47:
string(3) "end"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-23 12:51 UTC] cmb@php.net
-Status: Open +Status: Verified -Operating System: Linux +Operating System: *
 [2016-03-23 12:56 UTC] nikic@php.net
This is how it's supposed to work. You can't change from or to a -1 assertion level at runtime, because it controls compile-time behavior. If you want to retain the ability to change the assertion level at runtime, you should be using zend.assertions=0 in your ini, instead of zend.assertions=-1.
 [2016-03-23 14:21 UTC] ildar dot aim at gmail dot com
Please, do not break an ability to enable asserts from php code.

In some case, developers do not have a write access to the php.ini file.

This old debug code does not work after upgrade to PHP7 without 

//Enable assertions
if (defined('DEVELOPMENT_MODE')) {
    // ini_set('zend.assertions', 1); // does not work without php.ini corrections
    assert_options(ASSERT_ACTIVE,   true);
    assert_options(ASSERT_BAIL,     false);
    assert_options(ASSERT_WARNING,  false);
    assert_options(ASSERT_CALLBACK, 'func_assert_failure_handler');
} else {
    assert_options(ASSERT_ACTIVE,   false);
}
 [2016-03-23 14:52 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem -Package: *General Issues +Package: *Configuration Issues
 [2016-03-23 14:52 UTC] cmb@php.net
> This is how it's supposed to work.

Oops! Of course. Actually, the error message makes that clear
("... completely ...").

> Please, do not break an ability to enable asserts from php code.

As Nikita pointed out, enabling assertions during runtime is
*impossible*, if zend.assertions = -1.

However, as the documentation isn't very clear about this issue,
I'm changing to doc bug.
 [2016-03-28 06:42 UTC] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&revision=338838
Log: Fix #71873: additional explanation for zend.assertions in ini.core
 [2016-03-28 06:43 UTC] krakjoe@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2016-03-28 06:43 UTC] krakjoe@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2020-02-07 06:07 UTC] phpdocbot@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=e1ff080a511ae0e12f5c0ac501a82f05686823f4
Log: Fix #71873: additional explanation for zend.assertions in ini.core
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 11:01:33 2024 UTC