Bug #53801 [Com]: Cannot Access Phar::mount()'ed Items From Web

From: Date: Mon, 24 Jan 2011 21:35:29 +0000
Subject: Bug #53801 [Com]: Cannot Access Phar::mount()'ed Items From Web
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-158150@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53801&edit=1 ID: 53801 Comment by: panman at traileyes dot com Reported by: panman at traileyes dot com Summary: Cannot Access Phar::mount()'ed Items From Web Status: Open Type: Bug Package: PHAR related Operating System: Win 7 32 bit PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2011-01-22 08:52:29] 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-22 04:41:31] panman at traileyes dot com Added the OS I'm on. ------------------------------------------------------------------------ [2011-01-21 05:24:07] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53801&edit=1

« previous php.bugs (#158150) next »