Bug #74185 [Opn->Fbk]: PHP periodically failing to populate superglobals

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=74185&edit=1

 ID:                 74185
 Updated by:         [email protected]
 Reported by:        robin at willowsv dot com
 Summary:            PHP periodically failing to populate superglobals
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Variables related
 Operating System:   Windows 7
 PHP Version:        7.1.2
 Block user comment: N
 Private report:     N

 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php-trunk-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/




Previous Comments:
------------------------------------------------------------------------
[2017-03-02 18:38:05] spam2 at rhsoft dot net

no idea what you try to tell me with "Don't seem to have an option for bytecode-caching" - nobody but you knows how your sevrer is configured and if it is using "opcache" or "wincache" or whatever is available for the redmond-gameloader - consult your phpinfo() output

------------------------------------------------------------------------
[2017-03-02 17:52:53] robin at willowsv dot com

Already tried playing with the JIT value.

Don't seem to have an option for bytecode-caching.

------------------------------------------------------------------------
[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] => [email protected]
    [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] => [email protected]
    [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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.