|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65211 file_exists() warns of open_basedir on existing file mis-used as directory
Submitted: 2013-07-05 17:05 UTC Modified: 2015-06-04 14:56 UTC
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: paolo at schiro dot it Assigned: cmb (profile)
Status: Duplicate Package: Safe Mode/open_basedir
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
28 + 42 = ?
Subscribe to this entry?

 [2013-07-05 17:05 UTC] paolo at schiro dot it
When open_basedir set file_exists() raise an open_basedir warning 
when checking a path which permitted by open_basedir but includes 
an existent file misused as directory.

Test script:
//create a file
$fhandle = fopen('existing-file-which-is-not-dir.txt', 'w');

//throw your mind away and use it as a directory
if (is_file('existing-file-which-is-not-dir.txt/test.html')) {
        print "File exists";
} else {
        print "File does not exist";

//show the error

Expected result:
is_file should return a FALSE and you should read "File does not exist".

Actual result:
In addition to "File does not exist", you'll get a warning that 
open_basedir restriction is in effect:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-19 18:05 UTC] mail+php at requinix dot net
Duplicate of
- bug 52065 "Warning about open_basedir restriction while accessing a file as 
- bug 53041 "is_file() and open_basedir" closed to due no feedback (@pajoye: yes)

tl;dr: bug is not about open_basedir itself but rather some code being unable to 
access the file (rightly so) and the calling code assuming the failure is because 
of open_basedir.
 [2014-05-07 19:28 UTC] info at ihead dot ru
File functions produce warning if argument is a path which starts with existing file.

ini_set('open_basedir', '.');

Expected result: 

Actual result: 
Warning: file_exists(): open_basedir restriction in effect. File(./index.php/.section.php) is not within the allowed path(s): (.) in ***/1.php on line 4

PHP 5.3, 5.4 affected.
PHP 5.2 not affected.
 [2015-06-04 14:56 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2015-06-04 14:56 UTC]
This is a duplicate of bug #52065.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 16:01:27 2024 UTC