|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78138 Opcache incorrectly handles PHAR files when validate_permission option enabled
Submitted: 2019-06-10 15:18 UTC Modified: 2019-06-11 10:55 UTC
From: alex at cgi-central dot net Assigned:
Status: Closed Package: opcache
PHP Version: 7.3.6 OS: Linux
Private report: No CVE-ID: None
 [2019-06-10 15:18 UTC] alex at cgi-central dot net
When option opcache.validate_permission is enabled, only first access to a file inside PHAR archive is succesfull. 

All the following attempts to include or require a file from PHAR archive fail with error
Warning: include(): Failed opening 'phar:///var/www/html/33.phar/test.php' for inclusion

In same time, file_get_contents('phar:///var/www/html/33.phar/test.php') works fine as expected, so that is definitely an opcache issue. It happens even with "opcache.enable" is set to "off", so there is no quick workaround.

Test script:
There is a short test script:

Expected result:
The index.php file expected to output "OK" on each run.

Actual result:
Only first-run displays "OK", the following runs display error 

Warning: include(): Failed opening 'phar:///var/www/html/33.phar/test.php' for inclusion


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-11 10:55 UTC] alex at cgi-central dot net
I've found a possible workaround, but anyway it is important to get this problem solved.

If file is included like this
  Phar::loadPhar(__DIR__ . '/33.phar', 'phar33');
  include 'phar://phar33/test.php';
instead of usual
  include ('phar://' . __DIR__ . '/33.phar/test.php');

Then it works without any issues.
 [2019-06-11 14:50 UTC] alex at cgi-central dot net
The following pull request has been associated:

Patch Name: Fix for Bug #78138 - opcache.validate_permission incorrectly handles PHAR
On GitHub:
 [2019-07-02 10:29 UTC]
Automatic comment on behalf of
Log: Fix bug #78138: opcache.validate_permission incorrectly works with PHAR files
 [2019-07-02 10:29 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Feb 25 20:01:28 2024 UTC