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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cweiske@php.net
New email:
PHP Version: OS:

 

 [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: Thu Apr 25 09:01:29 2024 UTC