Bug #75005 [Opn->Csd]: Opcache causes strange behavior for superglobal vars
| From: | nikic@php.net | Date: | Sun, 17 Dec 2017 21:52:18 +0000 |
| Subject: | Bug #75005 [Opn->Csd]: Opcache causes strange behavior for superglobal vars | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213156@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75005&edit=1
ID: 75005
Updated by: nikic@php.net
Reported by: ps3bl at mail dot ru
Summary: Opcache causes strange behavior for superglobal vars
-Status: Open
+Status: Closed
Type: Bug
Package: opcache
Operating System: Windows 10 x64
PHP Version: 7.2.0beta1
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
As mentioned in the previous comment, this issue has been fixed in the meantime, so closing here.
Previous Comments:
------------------------------------------------------------------------
[2017-07-29 20:12:02] spam2 at rhsoft dot net
get the latest master anything startinh with 7.2.0 alpha1 was horrible broken and the bug below as
fixed at the same day in trunk
-------- Weitergeleitete Nachricht --------
Betreff: [PHP-DEV] oh my god -> Re: [PHP-DEV] PHP 7.2.0 is broken since the first alpha ->
opcache backtrace
Datum: Sat, 22 Jul 2017 08:43:44 +0200
Von: lists@rhsoft.net <lists@rhsoft.net>
An: internals@lists.php.net
i would say that is pretty one of the biggest major bugs i have ever seen because as you can see
here even that single code snippet alone is enough and the variable $cms_https_only is explicitly
set to 0 the line before
even if you change it to if($cms_https_only === 1 && empty($_SERVER['HTTPS'])
&& !empty($_SERVER['REQUEST_URI']) && PHP_SAPI !== 'cli') the
if-condition is executed
well, that explains the endless 301 perfectly.....
_________________________________
[harry@srv-rhsoft:~]$ curl http://corecms.testserver.rhsoft.net/opcache.php
<div
style='background-color:yellow;color:red;padding:3px;font-family:verdana;font-size:10px;'><br
/>
<b>Notice</b>: Undefined variable: cl_api in
<b>/Volumes/dune/www-servers/corecms/opcache.php</b> on line <b>6</b><br
/>
</div><div
style='background-color:yellow;color:red;padding:3px;font-family:verdana;font-size:10px;'><br
/>
<b>Fatal error</b>: Uncaught Error: Call to a member function location() on null in
/Volumes/dune/www-servers/corecms/opcache.php:6
Stack trace:
#0 {main}
thrown in <b>/Volumes/dune/www-servers/corecms/opcache.php</b> on line
<b>6</b><br />
</div>
_________________________________
[root@testserver:~]$ cat /www/corecms/opcache.php
<?php declare(strict_types=1);
$cms_https_only = 0;
if($cms_https_only === 1 && empty($_SERVER['HTTPS']) &&
!empty($_SERVER['REQUEST_URI']) && PHP_SAPI !== 'cli')
{
$cl_api->location(str_replace(PROTOCOL_PREFIX , 'https://', rh_serverurl) . $_SERVER['REQUEST_URI'],
/**$permanent*/1);
}
_________________________________
------------------------------------------------------------------------
[2017-07-29 20:06:47] ps3bl at mail dot ru
Description:
------------
While !(true || false) must return false, it returns true.
Only in PHP 7.2.0beta1 (x64, TS) and only when opcache is enabled.
php.ini:
opcache.enable=1
opcache.enable_cli=0
opcache.use_cwd=1
opcache.validate_timestamps=1
opcache.save_comments=1
Test script:
---------------
var_dump(in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']),
PHP_SAPI === 'cli-server');
var_dump(!(in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) ||
PHP_SAPI === 'cli-server'));
Expected result:
----------------
E:\Program Files\Apache24\htdocs\organizer.local\web\app_dev.php:15:boolean true
E:\Program Files\Apache24\htdocs\organizer.local\web\app_dev.php:15:boolean false
E:\Program Files\Apache24\htdocs\organizer.local\web\app_dev.php:16:boolean false
Actual result:
--------------
E:\Program Files\Apache24\htdocs\organizer.local\web\app_dev.php:15:boolean true
E:\Program Files\Apache24\htdocs\organizer.local\web\app_dev.php:15:boolean false
E:\Program Files\Apache24\htdocs\organizer.local\web\app_dev.php:16:boolean true
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75005&edit=1