Doc->Bug #66678 [Nab->Opn]: file_exists() no longer works as expected due to URL wrappers
| From: | hm2k@php.net | Date: | Mon, 10 Feb 2014 10:48:27 +0000 |
| Subject: | Doc->Bug #66678 [Nab->Opn]: file_exists() no longer works as expected due to URL wrappers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-184234@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66678&edit=1
ID: 66678
Updated by: hm2k@php.net
Reported by: hm2k@php.net
Summary: file_exists() no longer works as expected due to URL
wrappers
-Status: Not a bug
+Status: Open
-Type: Documentation Problem
+Type: Bug
Package: Filesystem function related
PHP Version: 5.4.25
Block user comment: N
Private report: N
New Comment:
Unexpected behaviour is a bug.
Previous Comments:
------------------------------------------------------------------------
[2014-02-09 17:22:15] bjori@php.net
.
------------------------------------------------------------------------
[2014-02-09 11:30:04] hm2k@php.net
Description:
------------
For Context: "Tip
As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to Supported Protocols
and Wrappers to determine which wrappers support stat() family of functionality."
You'll note that file_exists() is listed as a "file system function", yet it no
longer behaves as expected due to the URL wrappers.
This means you can no longer use the file_exists() to ensure that a file does exist on the local
file system, as it may equally exist (or not exist) on a remote URL.
I therefore propose that file_exists() be renamed to schlesingers_file_exists() as at least this
would make sense.
---
From manual page: http://www.php.net/function.file-exists
---
Test script:
---------------
<pre>
<?php
$files = array();
$files[] = php_ini_loaded_file(); //a file that always exists
$files[] = 'ftp://ftp.gnu.org/'; //a file that is
a URL
foreach ($files as $file) {
if (file_exists($file)) {
echo "'$file' file exists\n";
}
}
?>
Expected result:
----------------
You would expect file_exists() to only be true if the file exists on the local file system.
Actual result:
--------------
file_exists() will return true if the file does (or does not) exist on a remote URL.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66678&edit=1