php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75005 Opcache causes strange behavior for superglobal vars
Submitted: 2017-07-29 20:06 UTC Modified: 2017-12-17 21:52 UTC
From: ps3bl at mail dot ru Assigned: nikic (profile)
Status: Closed Package: opcache
PHP Version: 7.2.0beta1 OS: Windows 10 x64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ps3bl at mail dot ru
New email:
PHP Version: OS:

 

 [2017-07-29 20:06 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-29 20:12 UTC] 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-12-17 21:52 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2017-12-17 21:52 UTC] nikic@php.net
As mentioned in the previous comment, this issue has been fixed in the meantime, so closing here.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC