php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55832 is_file() returns true if file does NOT exist
Submitted: 2011-10-02 14:12 UTC Modified: 2011-10-04 12:55 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: christian dot koncilia at gmx dot net Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.3.8 OS: Windows 7
Private report: No CVE-ID: None
 [2011-10-02 14:12 UTC] christian dot koncilia at gmx dot net
Description:
------------
Using Windows 7, create a directory "C:\dirtest\Au". Run the test script. Output produced is: 

bool(true)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)

although neither $file1 nor $file2 exist! Expected output would be "bool(false)" in all cases.

Test script:
---------------
<?php
$file1 = 'C:\dirtest\Au\aux.gtb';
$file2 = 'C:\dirtest\Au\bux.gtb';

var_dump(is_file($file1));
var_dump(file_exists($file1));
var_dump(is_readable($file1));

var_dump(is_file($file2));
var_dump(file_exists($file2));
var_dump(is_readable($file2));

Expected result:
----------------
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)

Actual result:
--------------
bool(true)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-04 10:55 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2011-10-04 10:55 UTC] cataphract@php.net
Expected behavior. See DOS device names. This is an idiosyncrasy of the windows API.
 [2011-10-04 12:55 UTC] pajoye@php.net
This is a wrong explanation.

It is by no mean due to the Win32 API idiosyncrasy but the usage of 
FindFirstFile. Its behavior is clearly documented (http://msdn.microsoft.com/en-
us/library/windows/desktop/aa364418(v=vs.85).aspx) and we should actually stop 
to use it in realpath and related functions.

By doing so we also have to do the case conversion manually as well (btw, 
amazing that we have to do that for the case insensitive filesystem ;).

However, I keep this bug as bogus as we already have a feature request to solve 
this problem.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 06:01:35 2024 UTC