Bug #74185 [NEW]: PHP periodically failing to populate superglobals

From: Date: Tue, 28 Feb 2017 18:09:09 +0000
Subject: Bug #74185 [NEW]: PHP periodically failing to populate superglobals
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207614@lists.php.net to get a copy of this message
From:             robin at willowsv dot com
Operating system: Windows 7
PHP version:      7.1.2
Package:          Variables related
Bug Type:         Bug
Bug description:PHP periodically failing to populate superglobals

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 bug report at https://bugs.php.net/bug.php?id=74185&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=74185&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=74185&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=74185&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=74185&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=74185&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=74185&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=74185&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=74185&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=74185&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=74185&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=74185&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=74185&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=74185&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74185&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=74185&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=74185&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=74185&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74185&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=74185&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=74185&r=mysqlcfg



Thread (21 messages)

« previous php.bugs (#207614) next »