|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-02-19 14:31 UTC] djbrainnrg at gmail dot com
Description: ------------ Coming from this 64bit build -> http://windows.php.net/downloads/snaps/master/r400e65e/php-master-ts-windows-vc11-x64-r400e65e.zip Running with apache 2.4.12 Win64. For an unknown reason sometimes, very rare, the variable $_SERVER isn't available -> I have the failure everytime at the same place but i cannot provide a reproducable example because that only happens in combination with our used framework. Also it only happens on the third request in a row. Request 1: Main Page Load - Normal GET request Request 2: Ajax Request to another page - Loaded directly on pageload Request 3: Ajax Request to another page - Loaded directly on pageload => Error happens here I can prevent the failure by adding just the line $_SERVER; at the begin of the script execution chain, lets say on the entry page. Also i can prevent this failure with this option disabled in auto_globals_jit = Off in php.ini Full debug_backtrace bellow, i know it may not help that mutch but i don't have anything better for debugging right now. Test script: --------------- Cannot provide an example yet. Actual result: -------------- Notice: Undefined variable: _SERVER in C:\www\ouced\live\modules\Ouced\src\class\Request.class.php on line 198 array(11) { [0]=> array(7) { ["file"]=> string(42) "C:\www\ouced\live\modules\Caritas\init.php" ["line"]=> int(66) ["function"]=> string(7) "getHost" ["class"]=> string(13) "Ouced_Request" ["object"]=> object(Ouced_Request)#17 (1) { ["headers":"Ouced_Request":private]=> NULL } ["type"]=> string(2) "->" ["args"]=> array(0) { } } [1]=> array(4) { ["file"]=> string(59) "C:\www\ouced\live\modules\Ouced\src\class\FS\File.class.php" ["line"]=> int(408) ["args"]=> array(1) { [0]=> string(42) "C:\www\ouced\live\modules\Caritas\init.php" } ["function"]=> string(12) "include_once" } [2]=> array(7) { ["file"]=> string(58) "C:\www\ouced\live\modules\Ouced\src\class\Module.class.php" ["line"]=> int(65) ["function"]=> string(11) "includeFile" ["class"]=> string(13) "Ouced_FS_File" ["object"]=> object(Ouced_FS_File)#15 (11) { ["directory":"Ouced_FS_File":private]=> NULL ["filename":"Ouced_FS_File":private]=> NULL ["filenameHash":"Ouced_FS_File":private]=> NULL ["extension":"Ouced_FS_File":private]=> NULL ["filesize":"Ouced_FS_File":private]=> NULL ["accessTime":"Ouced_FS_File":private]=> NULL ["modificationTime":"Ouced_FS_File":private]=> NULL ["contents":"Ouced_FS_File":private]=> NULL ["alias":"Ouced_FS_File":private]=> NULL ["absolutePath"]=> string(42) "C:\www\ouced\live\modules\Caritas\init.php" ["relativePath"]=> string(24) "modules\Caritas\init.php" } ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> bool(true) [1]=> bool(false) } } [3]=> array(6) { ["file"]=> string(63) "C:\www\ouced\live\modules\Ouced\src\class\Initializer.class.php" ["line"]=> int(77) ["function"]=> string(14) "registerModule" ["class"]=> string(12) "Ouced_Module" ["type"]=> string(2) "::" ["args"]=> array(1) { [0]=> string(7) "Caritas" } } [4]=> array(6) { ["file"]=> string(53) "C:\www\ouced\live\modules\Ruh\config\basic.config.php" ["line"]=> int(36) ["function"]=> string(14) "registerModule" ["class"]=> string(17) "Ouced_Initializer" ["type"]=> string(2) "::" ["args"]=> array(1) { [0]=> string(7) "Caritas" } } [5]=> array(4) { ["file"]=> string(59) "C:\www\ouced\live\modules\Ouced\src\class\FS\File.class.php" ["line"]=> int(408) ["args"]=> array(1) { [0]=> string(53) "C:\www\ouced\live\modules\Ruh\config\basic.config.php" } ["function"]=> string(12) "include_once" } [6]=> array(7) { ["file"]=> string(58) "C:\www\ouced\live\modules\Ouced\src\class\Module.class.php" ["line"]=> int(60) ["function"]=> string(11) "includeFile" ["class"]=> string(13) "Ouced_FS_File" ["object"]=> object(Ouced_FS_File)#6 (11) { ["directory":"Ouced_FS_File":private]=> NULL ["filename":"Ouced_FS_File":private]=> NULL ["filenameHash":"Ouced_FS_File":private]=> NULL ["extension":"Ouced_FS_File":private]=> NULL ["filesize":"Ouced_FS_File":private]=> NULL ["accessTime":"Ouced_FS_File":private]=> NULL ["modificationTime":"Ouced_FS_File":private]=> NULL ["contents":"Ouced_FS_File":private]=> NULL ["alias":"Ouced_FS_File":private]=> NULL ["absolutePath"]=> string(53) "C:\www\ouced\live\modules\Ruh\config\basic.config.php" ["relativePath"]=> string(35) "modules\Ruh\config\basic.config.php" } ["type"]=> string(2) "->" ["args"]=> array(0) { } } [7]=> array(6) { ["file"]=> string(57) "C:\www\ouced\live\modules\Ouced\src\class\Ouced.class.php" ["line"]=> int(164) ["function"]=> string(14) "registerModule" ["class"]=> string(12) "Ouced_Module" ["type"]=> string(2) "::" ["args"]=> array(2) { [0]=> string(3) "Ruh" [1]=> bool(true) } } [8]=> array(7) { ["file"]=> string(57) "C:\www\ouced\live\modules\Ouced\src\class\Ouced.class.php" ["line"]=> int(223) ["function"]=> string(8) "initCore" ["class"]=> string(5) "Ouced" ["object"]=> object(Ouced)#1 (0) { } ["type"]=> string(2) "->" ["args"]=> array(0) { } } [9]=> array(7) { ["file"]=> string(40) "C:\www\ouced\live\modules\Ouced\init.php" ["line"]=> int(13) ["function"]=> string(16) "startApplication" ["class"]=> string(5) "Ouced" ["object"]=> object(Ouced)#1 (0) { } ["type"]=> string(2) "->" ["args"]=> array(0) { } } [10]=> array(4) { ["file"]=> string(46) "C:\www\ouced\live\modules\Ruh\public\index.php" ["line"]=> int(8) ["args"]=> array(1) { [0]=> string(40) "C:\www\ouced\live\modules\Ouced\init.php" } ["function"]=> string(12) "include_once" } } PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
Ah sorry, here the code that throws the error. public function getHost(){ return getValueFromArray($_SERVER, "HTTP_HOST"); } and getValueFromArray is function getValueFromArray(array $arr, $key){ if(isset($arr[$key])){ return $arr[$key]; } $levels = explode("[", $key); $c = count($levels); foreach($levels as $k => $level){ $level = trim($level, "[]"); if(!isset($arr[$level])){ return NULL; } $arr = $arr[$level]; } return $arr; }I run into the same issue with _REQUEST. The code below (from tt-rss): --- <?php ... if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); } $op = $_REQUEST["op"]; --- always fails to work properly, with "PHP Notice: Undefined variable: _REQUEST" in the last line. However adding a simple line: $_REQUEST; into the beginning of the script does work-around the issue.