Doc #66678 [NEW]: file_exists() no longer works as expected due to URL wrappers

From: Date: Sun, 09 Feb 2014 11:30:05 +0000
Subject: Doc #66678 [NEW]: file_exists() no longer works as expected due to URL wrappers
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10969@lists.php.net to get a copy of this message
From:             hm2k@php.net
Operating system: 
PHP version:      5.4.25
Package:          Filesystem function related
Bug Type:         Documentation Problem
Bug description:file_exists() no longer works as expected due to URL wrappers

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 bug report at https://bugs.php.net/bug.php?id=66678&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=66678&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=66678&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=66678&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=66678&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=66678&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=66678&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=66678&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=66678&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=66678&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=66678&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=66678&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=66678&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=66678&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66678&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=66678&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=66678&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=66678&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66678&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=66678&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=66678&r=mysqlcfg



Thread (2 messages)

« previous php.doc.bugs (#10969) next »