|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77183 $_SERVER is not set in preloaded classes
Submitted: 2018-11-20 15:38 UTC Modified: 2018-11-22 13:19 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: benjamin dot morel at gmail dot com Assigned:
Status: Open Package: opcache
PHP Version: master-Git-2018-11-20 (Git) OS: Fedora 29
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
48 + 36 = ?
Subscribe to this entry?

 [2018-11-20 15:38 UTC] benjamin dot morel at gmail dot com
When using a preloaded class that references $_SERVER, the variable is not set.
When setting auto_globals_jit to Off, it works.

Test script:


header('Content-Type: text/plain');




class Test {
        public static function getServer()
                return $_SERVER;




Expected result:

Actual result:
Notice: Undefined variable: _SERVER in /var/www/html/class.php on line 6


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-21 18:15 UTC]
Works for me.
 [2018-11-22 10:20 UTC] benjamin dot morel at gmail dot com
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:
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
 [2018-11-22 13:19 UTC]
> Restart php-fpm

Aha!  I've only tested on CLI; apparently, the issue only affects
some SAPIs.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jun 19 22:01:22 2021 UTC