Bug #71873 [Ver]: Warning:zend.assertions may be completely enabled or disabled only in php.ini

From: Date: Wed, 23 Mar 2016 14:21:38 +0000
Subject: Bug #71873 [Ver]: Warning:zend.assertions may be completely enabled or disabled only in php.ini
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200062@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71873&edit=1

 ID:                 71873
 User updated by:    ildar dot aim at gmail dot com
 Reported by:        ildar dot aim at gmail dot com
 Summary:            Warning:zend.assertions may be completely enabled or
                     disabled only in php.ini
 Status:             Verified
 Type:               Bug
 Package:            *General Issues
 Operating System:   *
 PHP Version:        7.0.4
 Block user comment: N
 Private report:     N

 New Comment:

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);
}


Previous Comments:
------------------------------------------------------------------------
[2016-03-23 12:56:23] 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 12:51:23] cmb@php.net

Indeed, there is obviously a contradiction in the code:
<https://github.com/php/php-src/blob/php-7.0.5RC1/Zend/zend.c#L121>
vs.
<https://github.com/php/php-src/blob/php-7.0.5RC1/Zend/zend.c#L132>.

------------------------------------------------------------------------
[2016-03-21 17:25:10] 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"



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=71873&edit=1


Thread (4 messages)

« previous php.bugs (#200062) next »