php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78240 Include/require doesn't seem to preload
Submitted: 2019-07-02 13:09 UTC Modified: 2019-07-14 04:22 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: brent at spatie dot be Assigned:
Status: No Feedback Package: opcache
PHP Version: 7.4.0alpha2 OS: macOS Mojave
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-07-02 13:09 UTC] brent at spatie dot be
Description:
------------
The `opcache.preload` documentation (https://php.net/manual/en/opcache.configuration.php#ini.opcache.preload) states:

"[…] either by includeing them or by using the opcache_compile_file() function"

However, using `include`, `include_once`, `require` or `require_once` doesn't seem to actually preload files.

Test script:
---------------
The source code: https://github.com/brendt/laravel-preload

The preload file: https://github.com/brendt/laravel-preload/blob/master/preload.php#L88

Tested by dumping `opcache_get_status()['scripts']` right after a server restart: https://github.com/brendt/laravel-preload/blob/master/routes/web.php#L16

Using `opcache_compile_file()`, 39 files are available, while only 16 files are available when using `require` or `include` (these are all non-class files)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-07-05 11:52 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2019-07-05 11:52 UTC] nikic@php.net
I can't reproduce this. Using require_once I get 859 preloaded classes. Using require I get a fatal error due to a redeclared class.
 [2019-07-14 04:22 UTC] php-bugs at lists dot php dot net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC