From:             benjcarson at digitaljunkies dot ca
Operating system: Linux
PHP version:      5CVS-2004-06-17 (dev)
PHP Bug Type:     Filesystem function related
Bug description:  Relative paths do not work with 'file://' stream wrapper

Description:
------------
When using fopen_wrappers, if a relative path is prepended with 'file://',
fopen() and friends fail and emit a warning about remote access being
unsupported for file access.  fopen() succeeds if 'file://' is omitted.

On a possibly related note, parse_url("file://test.php") returns
array(scheme => "file", host => "test.php").  I would imagine this is the
desired behaviour for remote protocols (e.g. 'http://php.net').  However,
if the fopen wrapper for 'file://' is calling parse_url() internally, this
could explain why the error message is complaining about remote hosts. 
I'm not familiar with the stream internals, though, so I might be way off
here...

And just in case anyone asks:

[EMAIL PROTECTED]:test$ php -r 'print_r(stream_get_wrappers());'
Array
(
    [0] => php
    [1] => file
    [2] => http
    [3] => ftp
    [4] => compress.bzip2
    [5] => compress.zlib
    [6] => https
    [7] => ftps
)



Reproduce code:
---------------
#!/usr/bin/php
<?php
// Note: 'test.php' exists in the current directory
$filename = "test.php";
$f1 = fopen($filename, "r");                       // works
$f2 = fopen("file://". $filename, "r");            // fails
$f3 = fopen(realpath($filename), "r");             // works
$f4 = fopen("file://" . realpath($filename), "r"); // works
?>

Expected result:
----------------
(no output)

Actual result:
--------------
Warning: fopen(): remote host file access not supported, file://test.php
in ./file_get_contents.php on line 6

Warning: fopen(file://test.php): failed to open stream: no suitable
wrapper could be found in ./file_get_contents.php on line 6


-- 
Edit bug report at http://bugs.php.net/?id=28820&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28820&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28820&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28820&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28820&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28820&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28820&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28820&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28820&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28820&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28820&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28820&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28820&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28820&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28820&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28820&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28820&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28820&r=float

Reply via email to