php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42638 Inconsistent behavior file_exists() & is_file() functions
Submitted: 2007-09-12 08:23 UTC Modified: 2008-08-26 01:00 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: kraghuba at in dot ibm dot com Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5CVS-2007-09-12 (snap) OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-09-12 08:23 UTC] kraghuba at in dot ibm dot com
Description:
------------
Inconsistent behaviour of file_exists() & is_file() functions when given filename end with a trailing slash

The functions: file_exists(), is_file() return inconsistent value on different OS when given
filename/path end with a trailing slash (/). On RHEL 5 and Windows XP that i have, it retuns false, which is expected. 

There have been some fixes done relating to this to get the consistent behavior( match Windows with 
Linux behavior on handling on trailing slash, Defect #42027) but I have noticed that on different platform( linux and varient ) 
the output differ. 

I think, this is something to do with the way realpath work on different OS.

Following are the testcases that continue to fail because of this on few linux and other Os but not on all(I have been watching the PHP-QA list and seen these failures): 

  1) is_file_variation4.phpt
  2) rename_variation.phpt



Reproduce code:
---------------
<?php
  fclose( fopen("test.tmp") );
  var_dump( is_file("test.tmp/") );
  var_dump( file_exists("test.tmp/") );
  unlink("test.tmp");
?>



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


Actual result:
--------------
Actual output ( on some of Linux and other OS, excluding Windows ):
-------------------------------------------------------------------
bool(true)
bool(true)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-13 09:55 UTC] jani@php.net
On what Linux does it misbehave? I get expected result with FC 6 (glibc 2.5, linux 2.6.20)

 [2007-09-13 10:16 UTC] kraghuba at in dot ibm dot com
I have gather the following system details where difference in behavior is noticed by looking at failure of rename_variation.phpt 
and is_file_variation4.phpt testcases on PHP-QA list:

Linux - Linux etch-demo 2.6.18-4-686 #1 SMP Wed May 9 23:03:12 UTC 2007 i686
HP-UX - HP-UX TS030 B.11.11 U 9000/785
Linux whclweb02.wrencheadcorp.com 2.6.9-42.0.3.ELhugemem #1 SMP Thu Oct 5 15:24:32 CDT 2006 i686
SunOS - SunOS goo 5.9 Generic_112233-10 sun4u
SunOS - SunOS kukui 5.8 Generic_117350-45 sun4u
Linux - Linux li17-117 2.6.21.1-linode32 #1 Sun May 6 17:50:51 EDT 2007 i686
Linux - Linux unmanaged 2.6.18-5-686 #1 SMP Thu Aug 30 02:19:07 UTC 2007 i686
FreeBSD - FreeBSD mint.netfront.net 6.2-STABLE FreeBSD 6.2-STABLE #0: Thu Sep  6 01:47:49 HKT 2007 
Linux - Linux screen-web2 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:27:17 EDT 2006 i686
Linux - Linux i008 2.6.20.3 #1 SMP Mon Jul 9 12:10:29 HKT 2007 i686
....
And many more.
 [2008-08-26 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 22:01:29 2019 UTC