|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-11-20 15:38 UTC] benjamin dot morel at gmail dot com
Description:
------------
When using a preloaded class that references $_SERVER, the variable is not set.
When setting auto_globals_jit to Off, it works.
Test script:
---------------
index.php
========
<?php
header('Content-Type: text/plain');
print_r(Test::getServer());
class.php
=========
<?php
class Test {
public static function getServer()
{
return $_SERVER;
}
}
preload.php
===========
<?php
opcache_compile_file('class.php');
Expected result:
----------------
Array(
...
)
Actual result:
--------------
Notice: Undefined variable: _SERVER in /var/www/html/class.php on line 6
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 23:00:01 2025 UTC |
Weird. I reproduced it again today with the latest master. Full reproduce steps: 1. Create /var/www/html/index.php as above 2. Create /var/www/html/class.php as above 3. Create /var/www/html/preload.php as above; change the path to an absolute path: opcache_compile_file('/var/www/html/class.php'); 4. Add this line to php.ini: opcache.preload = /var/www/html/preload.php 5. Restart php-fpm 6. Load http://localhost/ You should get the error: Notice: Undefined variable: _SERVER in /var/www/html/class.php on line 6