Bug #74185 [Opn]: PHP periodically failing to populate superglobals
| From: | robin at willowsv dot com | Date: | Thu, 02 Mar 2017 17:52:56 +0000 |
| Subject: | Bug #74185 [Opn]: PHP periodically failing to populate superglobals | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207666@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74185&edit=1
ID: 74185
User updated by: robin at willowsv dot com
Reported by: robin at willowsv dot com
Summary: PHP periodically failing to populate superglobals
Status: Open
Type: Bug
Package: Variables related
Operating System: Windows 7
PHP Version: 7.1.2
Block user comment: N
Private report: N
New Comment:
Already tried playing with the JIT value.
Don't seem to have an option for bytecode-caching.
Previous Comments:
------------------------------------------------------------------------
[2017-02-28 18:21:22] spam2 at rhsoft dot net
sounds like a bug in http://php.net/manual/en/ini.core.php#ini.auto-globals-jit
on windows and maybe related to bytecode cache - dunno if windows these days also is using opcache,
but you can try "auto_globals_jit = 0" and 0/1 in combination with and without
bytecode-caching
------------------------------------------------------------------------
[2017-02-28 18:16:53] robin at willowsv dot com
Not just $_COOKIE either
Severity: Notice --> Undefined variable: _GET D:\www\httpdocs\cms\system\core\Input.php 609
------------------------------------------------------------------------
[2017-02-28 18:09:00] robin at willowsv dot com
Description:
------------
Periodically PHP will periodically fail to populate the $_COOKIE Super global.
The logs will report that _COOKIE is undefined if you check it (depending on the reporting level)
and if it's set first it will behave like a non superglobal with normal variable scope.
A restart of the Apache/PHP server corrects the issue however it hits sporadically and refused to
allow us to sign in. $_SERVER reports cookie data is available.
Test script:
---------------
<?php
echo("Dumping Server!\n"); print_r($_SERVER);
echo("\n\nDumping Cookie!\n"); print_r($_COOKIE);
// Set Value
echo("\n\nSetting Cookie!\n"); $_COOKIE['TEST'] = "TEST";
print_r($_COOKIE);
// Echo
echo("\n\nTest 1!\n"); test();
echo("\n\nTest 2!\n"); test2();
// Test Function 1 (No Global)
function test() {
if ( empty($_COOKIE) )
echo("Can't find cookie superglobal!\n");
}
else {
echo("Dumping Cookie!\n");
print_r($_COOKIE);
}
}
// Test Function 2 (No Global)
function test2() {
global $_COOKIE;
if ( empty($_COOKIE) ) {
echo("Can't find cookie superglobal!");
}
else {
echo("Dumping Cookie!\n");
print_r($_COOKIE);
}
}
?>
Expected result:
----------------
Dumping Server!
Array
(
[HTTPS] => on
[SSL_SESSION_RESUMED] => Initial
[HTTP_HOST] => 10.224.130.232
[HTTP_CONNECTION] => keep-alive
[HTTP_CACHE_CONTROL] => max-age=0
[HTTP_UPGRADE_INSECURE_REQUESTS] => 1
[HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/56.0.2924.87 Safari/537.36
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
[HTTP_ACCEPT_ENCODING] => gzip, deflate, sdch, br
[HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.8,en-GB;q=0.6
[HTTP_COOKIE] => CMS=18368a69a2b9b1d7a62918213adcf19d;
SVMCMS=05bfdca9adaf72b52578668069db639f61652476; PHPSESSID=1b86072d4b839507ae6e7223f3645923
[SystemRoot] => C:\Windows
[COMSPEC] => C:\Windows\system32\cmd.exe
[WINDIR] => C:\Windows
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache/2.4.25 (Win32) OpenSSL/1.0.2k PHP/7.1.2
[SERVER_PORT] => 443
[DOCUMENT_ROOT] => D:/www/httpdocs
[REQUEST_SCHEME] => https
[CONTEXT_PREFIX] =>
[CONTEXT_DOCUMENT_ROOT] => D:/www/httpdocs
[SERVER_ADMIN] => admin@example.com
[SCRIPT_FILENAME] => D:/www/httpdocs/cms/bug.php
[REMOTE_PORT] => 62749
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /cms/bug.php
[SCRIPT_NAME] => /cms/bug.php
[PHP_SELF] => /cms/bug.php
[REQUEST_TIME_FLOAT] => 1488303793.707
[REQUEST_TIME] => 1488303793
[argv] => Array
(
)
[argc] => 0
)
Dumping Cookie!
Array
(
[CMS] => 18368a69a2b9b1d7a62918213adcf19d
[SVMCMS] => 05bfdca9adaf72b52578668069db639f61652476
[PHPSESSID] => 1b86072d4b839507ae6e7223f3645923
)
Setting Cookie!
Array
(
[CMS] => 18368a69a2b9b1d7a62918213adcf19d
[SVMCMS] => 05bfdca9adaf72b52578668069db639f61652476
[PHPSESSID] => 1b86072d4b839507ae6e7223f3645923
[TEST] => TEST
)
Test 1!
Dumping Cookie!
Array
(
[CMS] => 18368a69a2b9b1d7a62918213adcf19d
[SVMCMS] => 05bfdca9adaf72b52578668069db639f61652476
[PHPSESSID] => 1b86072d4b839507ae6e7223f3645923
[TEST] => TEST
)
Test 2!
Dumping Cookie!
Array
(
[CMS] => 18368a69a2b9b1d7a62918213adcf19d
[SVMCMS] => 05bfdca9adaf72b52578668069db639f61652476
[PHPSESSID] => 1b86072d4b839507ae6e7223f3645923
[TEST] => TEST
)
Actual result:
--------------
Dumping Server!
Array
(
[HTTPS] => on
[SSL_SESSION_RESUMED] => Resumed
[HTTP_HOST] => 10.224.130.232
[HTTP_CONNECTION] => keep-alive
[HTTP_CACHE_CONTROL] => max-age=0
[HTTP_UPGRADE_INSECURE_REQUESTS] => 1
[HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/56.0.2924.87 Safari/537.36
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
[HTTP_ACCEPT_ENCODING] => gzip, deflate, sdch, br
[HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.8,en-GB;q=0.6
[HTTP_COOKIE] => CMS=18368a69a2b9b1d7a62918213adcf19d;
SVMCMS=05bfdca9adaf72b52578668069db639f61652476; PHPSESSID=1b86072d4b839507ae6e7223f3645923
[SystemRoot] => C:\Windows
[WINDIR] => C:\Windows
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache/2.4.25 (Win32) OpenSSL/1.0.2k PHP/7.1.2
[SERVER_PORT] => 443
[DOCUMENT_ROOT] => D:/www/httpdocs
[REQUEST_SCHEME] => https
[CONTEXT_PREFIX] =>
[CONTEXT_DOCUMENT_ROOT] => D:/www/httpdocs
[SERVER_ADMIN] => admin@example.com
[SCRIPT_FILENAME] => D:/www/httpdocs/cms/bug.php
[REMOTE_PORT] => 62746
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /cms/bug.php
[SCRIPT_NAME] => /cms/bug.php
[PHP_SELF] => /cms/bug.php
[REQUEST_TIME_FLOAT] => 1488303761.429
[REQUEST_TIME] => 1488303761
[argv] => Array
(
)
[argc] => 0
)
Dumping Cookie!
Setting Cookie!
Array
(
[TEST] => TEST
)
Test 1!
Can't find cookie superglobal!
Test 2!
Dumping Cookie!
Array
(
[TEST] => TEST
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74185&edit=1