Re: OPcache optimizer improvement in PHP-5.5?
| From: | Stas Malyshev | Date: | Fri, 12 Apr 2013 21:09:33 +0000 |
| Subject: | Re: OPcache optimizer improvement in PHP-5.5? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67076@lists.php.net to get a copy of this message | ||
Hi!
> I don't think this is a safe optimization. In the following case it would
> output 'b' and not 'a' which is the correct result:
>
> a.php:
> <?php
> define('FOO', 'a');
> include('b.php');
> ?>
>
> b.php:
> <?php
> define('FOO', 'b');
> echo FOO;
> ?>
>
> It is certainly not likely for a constant to be defined twice but PHP
> currently just issues a notice and continues with the first constant value.
It's more likely than you think, especially given that on the way
between define and include there could be other code doing various
checks and calculations. In general, any optimization involving global
context is very dangerous in PHP since the script can be run in
different global contexts.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227