Bug #77183 [Fbk->NoF]: $_SERVER is not set in preloaded classes
| From: | php-bugs at lists dot php dot net | Date: | Sun, 26 Sep 2021 04:22:14 +0000 |
| Subject: | Bug #77183 [Fbk->NoF]: $_SERVER is not set in preloaded classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-236845@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77183&edit=1
ID: 77183
Updated by: php-bugs@lists.php.net
Reported by: benjamin dot morel at gmail dot com
Summary: $_SERVER is not set in preloaded classes
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: opcache
Operating System: Fedora 29
PHP Version: master-Git-2018-11-20 (Git)
Assigned To: cmb
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2021-09-14 13:58:42] cmb@php.net
Is this still unresolved with latest PHP 7.4? If so, would it
work if included class.php (opcache_compile_file() has known
limitations regarding preloading)?
------------------------------------------------------------------------
[2018-11-22 13:19:44] cmb@php.net
> Restart php-fpm
Aha! I've only tested on CLI; apparently, the issue only affects
some SAPIs.
------------------------------------------------------------------------
[2018-11-22 10:20:11] 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:
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
------------------------------------------------------------------------
[2018-11-21 18:15:54] cmb@php.net
Works for me.
------------------------------------------------------------------------
[2018-11-20 15:38:44] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77183&edit=1