php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76128 PHAR file detection is broken
Submitted: 2018-03-21 13:44 UTC Modified: 2018-08-14 16:46 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: kelunik@php.net Assigned:
Status: Open Package: PHAR related
PHP Version: 7.2.3 OS: Linux
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:
MUST BE VALID
Solve the problem:
16 + 49 = ?
Subscribe to this entry?

 
 [2018-03-21 13:44 UTC] kelunik@php.net
Description:
------------
Detecting the PHAR in a file path like 'phar:///home/kelunik/acme-client.phar/vendor/autoload.php' works, but it fails if there's no '.phar' extension. 'phar:///home/kelunik/acme-client/vendor/autoload.php' therefore doesn't work if the PHAR is renamed to 'acme-client'.

Finding the PHAR in such a path isn't possible with quite some I/O. Because of that, I propose to use a non-valid character such as a NUL-byte to separate the PHAR path from the path inside the PHAR.

I think Java uses ! or # or so as a separator.

Expected result:
----------------
File functions work regardless of the file name of the PHAR.

Actual result:
--------------
File functions are broken if the PHAR doesn't end with '.phar'.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-16 08:16 UTC] maikuolan at gmail dot com
#76061 and #76128 might be related (not sure).

https://bugs.php.net/bug.php?id=76061
https://bugs.php.net/bug.php?id=76128
 [2018-08-14 16:46 UTC] cmb@php.net
-Type: Bug +Type: Feature/Change Request
 [2018-08-14 16:46 UTC] cmb@php.net
The documentation states[1]:

| The file name's extension must contain .phar.

So this is not a bug, but rather a feature request, in my opinion.

[1] <http://php.net/manual/en/phar.construct.php>
 [2019-12-12 10:44 UTC] ojrask at gmail dot com
As it seems like a feature request, I would like to +1 the request. It would be nice to have a way to include/require PHARs without the extension in place, and let the developer handle situations where the file being loaded is not an actual PHAR.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 14:01:31 2024 UTC