php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67071 webPhar() does not work with symlinked files
Submitted: 2014-04-14 04:07 UTC Modified: 2017-05-04 11:02 UTC
From: cweiske@php.net Assigned:
Status: Duplicate Package: PHAR related
PHP Version: 5.4.27 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 !
Your email address:
MUST BE VALID
Solve the problem:
43 + 8 = ?
Subscribe to this entry?

 
 [2014-04-14 04:07 UTC] cweiske@php.net
Description:
------------
Running a symlinked .phar file through a web server makes Phar::webPhar() return, thus not detecting that it's running in a web environment.

The use case for symlinked phars is version updated. Suppose my .phar-released app has several version "test-0.0.1.phar" and "test-0.0.2.phar", but I don't want to expose that in the browser URL. So I simply symlink test.phar to test-0.0.1.phar, and updating simply means changing the symlink to point to test-0.0.2.phar.

Steps to reproduce:

1. Create the phar with the given test script
2. Open phar in browser, you'll get "web".
3. Symlink it to test2.phar
4. Open test2.phar in browser, you'll get "cli".


Test script:
---------------
<?php
if (file_exists('test.phar')) {
    unlink('test.phar');
}
$phar = new Phar('test.phar');
$phar->addFromString('www/index.php', '<?php echo "web";?>');
$phar->setStub(
    '<?php Phar::webPhar(null, "www/index.php"); echo "cli\n"; __HALT_COMPILER(); ?>'
);
?>


Expected result:
----------------
"web" from test2.phar

Actual result:
--------------
"cli" from test2.phar

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-04 11:02 UTC] cweiske@php.net
-Status: Open +Status: Duplicate
 [2017-05-04 11:02 UTC] cweiske@php.net
Duplicate of bug #52322 - it has the same cause.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 10 23:01:30 2024 UTC