Bug 1357459

Summary: Non-default value in php.ini an undocumented breaking change in PHP7
Product: [Fedora] Fedora Reporter: James Hogarth <james.hogarth>
Component: phpAssignee: Remi Collet <fedora>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: fedora, jorton
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-26 07:16:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description James Hogarth 2016-07-18 09:37:45 UTC
Description of problem:
The php ini option zend.assertions differs from upstream in the Fedora build. Upstream has a backwards compatible value of 0 so that assert() gets compiled and executed. The present rawhide build has a value of -1 so any assert() is not even compiled. 

This change is not documented on the F25 changeset and breaks any application or testsuite using assert() to validate data before acting on it. 

Version-Release number of selected component (if applicable):
php-cli-7.0.9-0.1.RC1.fc25.x86_64

How reproducible:
always

Steps to Reproduce:
1. Reduced sample:
<?php

$testvar="a";

assert('is_bool($testvar)');

print "this is a test\n";

2. php test.php
3. php -n test.php

Actual results:
this is a test

Expected results:
Warning: assert(): Assertion "is_bool($testvar)" failed in /root/test.php on line 5
this is a test


Additional info:
According to the RFC that implemented the zend.assertions change for PHP7 the defaults are to be backwards compatible with PHP5 code, and to go to PHP7 only mode an application should actively change the parameters. 

https://github.com/tpunt/PHP7-Reference#expectations
https://wiki.php.net/rfc/expectations

Note that this is a breaking change from previous and any application that uses assert() to verify something before acting on it will be broken by the deviation from upstream in this.

This will also serve to confuse those who have read up on PHP7 changes in preparation for F25 and this undocumented deviation from upstream will cause unexpected behaviour where PHP libraries test against upstream defaults with tools like Travis CI.

Please document a workaround for libraries that make use of assertions - particularly in their test suites - or preferably revert to match the upstream defaults.

Comment 1 Remi Collet 2016-07-18 09:49:57 UTC
Default upstream value for "production" is -1, so this is expected.

[Assertion]
; Switch whether to compile assertions at all (to have no overhead at run-time)
; -1: Do not compile at all
;  0: Jump over assertion at run-time
;  1: Execute assertions
; Changing from or[Assertion]
; Switch whether to compile assertions at all (to have no overhead at run-time)
; -1: Do not compile at all
;  0: Jump over assertion at run-time
;  1: Execute assertions
; Changing from or to a negative value is only possible in php.ini! (For turning assertions on and off at run-time, see assert.active, when zend.assertions = 1)
; Default Value: 1
; Development Value: 1
; Production Value: -1
; http://php.net/zend.assertions
zend.assertions = -1
 to a negative value is only possible in php.ini! (For turning assertions on and off at run-time, see assert.active, when zend.assertions = 1)
; Default Value: 1
; Development Value: 1
; Production Value: -1
; http://php.net/zend.assertions
zend.assertions = -1


Sorry, but I don't think we should change this value, as we always use php.ini-production as a template for our php.ini

You still can use  -d zend.assertions=1 at runtime

Comment 2 Jan Kurik 2016-07-26 04:17:05 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 25 development cycle.
Changing version to '25'.