Bug #68765 [ReO->Csd]: Optimisation of constant definitions can cause incorrect output.
| From: | nikic@php.net | Date: | Fri, 23 Jun 2017 15:50:44 +0000 |
| Subject: | Bug #68765 [ReO->Csd]: Optimisation of constant definitions can cause incorrect output. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209659@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68765&edit=1
ID: 68765
Updated by: nikic@php.net
Reported by: axel dot ml at warenform dot net
Summary: Optimisation of constant definitions can cause
incorrect output.
-Status: Re-Opened
+Status: Closed
Type: Bug
Package: opcache
Operating System: Linux x86_64
PHP Version: 5.6.4
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
This has been fixed at some point with the addition of the ZEND_OPTIMIZER_PASS_15 ("collect
constants") flag, which is disabled by default.
Previous Comments:
------------------------------------------------------------------------
[2015-03-13 11:49:36] v dot leborgne at shop-application dot com
I've done some more tests :
PHP 5.6.6 and opcache disabled : "hello world"
PHP 5.6.6 and opcache enabled: "hi world"
PHP 5.5.22 and opcache disabled : "hello world"
PHP 5.5.22 and opcache enabled : "hello world"
------------------------------------------------------------------------
[2015-03-13 11:39:22] v dot leborgne at shop-application dot com
I experience the same issue with php 5.6.6 :
myscript.php :
define('FOO','hello');
include('somefile.php');
echo ANOTHER_FOO;
somefile.php :
define('FOO','hi');
define('ANOTHER_FOO',FOO.' world');
myscript.php prints :
in PHP<5.6 : "hello world"
in PHP5.6 : "hi world"
------------------------------------------------------------------------
[2015-01-07 19:23:54] leigh@php.net
Apologies I didn't read properly.
It seems to me this is unrelated to the @ operator at all then (yes the current bug title is
misleading - I'll try and think of something more appropriate), as you state yourself, if you
omit all of the @ operators the problem persists.
I suspect there is some kind of optimisation being performed, and OpCache noticing that the include
file has not changed, simply spits out the optimised output even though the execution conditions
have changed.
------------------------------------------------------------------------
[2015-01-07 18:52:34] axel dot ml at warenform dot net
I admit using an "@" here is misleading. But if you omit all "@"s the problem is
still the same: The code behaves different, when turning opcache on. The seems to be a bug for me.
------------------------------------------------------------------------
[2015-01-07 15:58:08] leigh@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The @ operator is not a conditional construct. It prevents any error from being displayed, it does
not prevent the statement from executing.
Checking the constant with
if (!defined(...)) is the correct way to handle this
situation.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=68765
--
Edit this bug report at https://bugs.php.net/bug.php?id=68765&edit=1