php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53801 Cannot Access Phar::mount()'ed Items From Web
Submitted: 2011-01-21 05:24 UTC Modified: 2011-01-22 08:52 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: panman at traileyes dot com Assigned:
Status: Open Package: PHAR related
PHP Version: 5.3.5 OS: Win 7 32 bit
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: panman at traileyes dot com
New email:
PHP Version: OS:

 

 [2011-01-21 05:24 UTC] panman at traileyes dot com
Description:
------------
Using the mount() method brings in files/folders so that PHP scripts can use them internally. However, those files are not accessible through the Web server as the built-in files are. The directory structure should be as follows for the test below:

make.php = The test script below
internal.html = <p>From the inside</p>
external.html = <p>From the outside</p>
include.php = <?php include 'external.html'; ?>
test.phar = Will be built from the test script

Test script:
---------------
<?php
try {
    $p = new Phar('test.phar');
    $p->addFile('internal.html');
    $p->addFile('include.php');
    $p->setStub('<?php
Phar::webPhar("test.phar", "internal.html");
Phar::mount(__DIR__ . "/external.html", "external.html");
__HALT_COMPILER();');
    echo 'Done making test.phar';
} catch (Exception $e) {
    echo 'Exception caught: ' . $e->getMessage();
}
?>

Expected result:
----------------
Visiting: make.php
Done making test.phar

Visiting: test.phar/internal.html
From the inside

Visiting: test.phar/external.html
From the outside

Visiting: test.phar/include.php
From the outside

Actual result:
--------------
Visiting: make.php
Done making test.phar

Visiting: test.phar/internal.html
From the inside

Visiting: test.phar/external.html
404 - File /external.html Not Found

Visiting: test.phar/include.php
From the outside

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-22 04:41 UTC] panman at traileyes dot com
-Summary: Cannot Access mount()'ed Items From Web +Summary: Cannot Access Phar::mount()'ed Items From Web -Operating System: +Operating System: Win 7 32 bit
 [2011-01-22 04:41 UTC] panman at traileyes dot com
Added the OS I'm on.
 [2011-01-22 08:52 UTC] panman at traileyes dot com
I was thinking about this some more and came up with a possible reason why this doesn't work, along with bug 53809. The Phar's manifest is registered when Phar::mapPhar() or Phar::webPhar() is called. Well, since the files that are Phar::mount()'ed come after one of the "loading" methods then those files are not included in the manifest.

I tried to fix this by moving the Phar::mount()'s before the Phar::webPhar() but that didn't work. I'm thinking that's because Phar::mount() won't work until it can look at a loaded manifest.

I also tried calling Phar::mapPhar() after the Phar::mount()'s but that didn't do anything. Not sure if it doesn't re-load the manifest after it's been loaded once...

Anyway, it would be nice if Phar::mount() would register itself with the manifest automatically or have Phar::mapPhar() re-load the manifest, including the Phar::mount()'ed files.
 [2011-01-24 22:35 UTC] panman at traileyes dot com
So it doesn't seem to be manifest related as I took a look at the source code and 
phar_mount_entry does appear to be adding the path to both mounted_dirs hash and 
manifest hash. I'm not fluent in C so I don't know how to properly read all of the 
source code. If I had to guess, it's something how Phar::webPhar() works. Will try 
to dig into this further when I get some more time.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC