php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52769 realpath not working inside phar
Submitted: 2010-09-03 12:45 UTC Modified: 2015-03-30 18:54 UTC
Votes:26
Avg. Score:4.7 ± 0.6
Reproduced:23 of 24 (95.8%)
Same Version:7 (30.4%)
Same OS:17 (73.9%)
From: miha dot vrhovnik at domenca dot com Assigned:
Status: Not a bug Package: PHAR related
PHP Version: 5.3.3 OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: miha dot vrhovnik at domenca dot com
New email:
PHP Version: OS:

 

 [2010-09-03 12:45 UTC] miha dot vrhovnik at domenca dot com
Description:
------------
When you run a realpath returns false when run on phar paths.

Test script:
---------------
put a test script inside \foo\bar\test.php

and create a phar where \bar\test.php is inisde it

run created phar..

<?php

echo (realpath(dirname(__FILE__) . '/../'));

Expected result:
----------------
see the full path

Actual result:
--------------
nothing

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-15 16:01 UTC] felipe@php.net
Probably related to bug #51806
 [2011-11-20 00:43 UTC] maks dot slesarenko at gmail dot com
Hi, I'm not PHP Core developer, just developer using php :)

I think this is not a bug, functions like chmod, chown and realpath, glob are working only with "file://" stream. And this is correct! realpath() always should provide "real" path on filesytem (file://), not in phar, zip, http or myOwnStream.

I can not even imagine what how it will be in other case for ex. realpath('myRegisteredStream://somepath')
or chmod('http://google.com', 777) - funny isn't it?!
 [2011-11-20 08:42 UTC] maks dot slesarenko at gmail dot com
In my scripts I do something like this:

define('APPLICATION_PATH', __DIR__); -- path inside phar for loading files
define('REAL_PATH', realpath('.')) -- folder where php was called
 [2015-03-30 18:53 UTC] mike@php.net
-Status: Open +Status: Not a bug
 [2015-03-30 18:53 UTC] mike@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 [2015-03-30 18:54 UTC] mike@php.net
realpath() is supposed to return a real path, not a, well, virtual one.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC