php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alex at cgi-central dot net
New email:
PHP Version: OS:

 

 [2019-06-10 15:18 UTC] alex at cgi-central dot net
Description:
------------
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:
 https://github.com/alex-scott/php-phar-bug

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

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

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:  https://github.com/php/php-src/pull/4252
Patch:      https://github.com/php/php-src/pull/4252.patch
 [2019-07-02 10:29 UTC] nikic@php.net
Automatic comment on behalf of alex@cgi-central.net
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a4acff3e21778e8d1f635cf74611b1c13de5ee2a
Log: Fix bug #78138: opcache.validate_permission incorrectly works with PHAR files
 [2019-07-02 10:29 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC