php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32771 is_dir() returns false for absolute path. Even if it is a folder
Submitted: 2005-04-19 17:31 UTC Modified: 2010-12-20 11:53 UTC
Votes:5
Avg. Score:4.6 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:4 (100.0%)
From: silkensedai at online dot fr Assigned: wez (profile)
Status: Not a bug Package: Safe Mode/open_basedir
PHP Version: 5.0.4 OS: GNU/Linux Ubuntu 5.4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: silkensedai at online dot fr
New email:
PHP Version: OS:

 

 [2005-04-19 17:31 UTC] silkensedai at online dot fr
Description:
------------
is_dir() does not work when the folder is an absolute path.

For example is_dir('/mnt') won't work (return false).
But it works for relative path.

Example:

$ php -r 'clearstatcache();var_dump(is_dir("/mnt/"));' bool(false)
$ php -r 'clearstatcache();var_dump(is_dir("./Templates"));'
bool(true)
$ test -d "/mnt/" && echo dir || echo not_dir
dir
$ test -d "./Templates" && echo dir || echo not_dir
dir


From phpinfo(): PHP Version 5.0.4
System:	Linux louve 2.6.10-5-386 #1 Tue Apr 5 12:12:40 UTC 2005 i686
Configure Command:	'./configure' '--quiet' '--enable-cli' '--enable-cgi' '--disable-all' '--disable-rpath' '--disable-debug' '--disable-path-info-check' '--disable-magic-quotes' '--disable-posix' '--disable-short-tags' '--enable-ipv6' '--disable-static' '--disable-pcntl' '--without-pear' '--with-apxs2=/usr/bin/apxs2' '--with-mysql=/usr' '--with-mysqli=/usr/bin/mysql_config' '--with-zlib' '--with-bz2' '--with-dbx' '--with-ctype' '--with-openssl' '--with-pcre-regex' '--with-gettext' '--with-mcrypt' '--with-mhash' '--with-iconv' '--with-sqlite' '--with-sqlite-utf8' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-zlib-dir' '--with-xpm-dir' '--with-ttf' '--with-xsl' '--with-tsrm-pthreads' '--with-tidy' '--with-freetype-dir' '--enable-gd-native-ttf' '--enable-safe-mode' '--enable-calendar' '--enable-mbstring' '--enable-spl' '--enable-ftp' '--enable-bcmath' '--enable-sockets' '--enable-dom' '--enable-xml' '--enable-soap' '--enable-libxml' '--enable-session' '--enable-simplexml' '--enable-memory-limit'
Server API 	Apache 2.0 Handler
PHP API 	20031224
PHP Extension 	20041030
Zend Extension 	220040412 

Reproduce code:
---------------
print is_dir('/')?"dir: /":"not_dir: /";

Expected result:
----------------
dir: /

Actual result:
--------------
not_dir: /

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-19 17:56 UTC] silkensedai at online dot fr
Also: safe mode is enabled
 [2005-04-19 22:06 UTC] tony2001@php.net
is_file() does the same thing when the owner of the file is not the owner of the script.
IMO that's how safe_mode works. 
Wez, is this the expected behaviour or am I wrong?
 [2005-08-11 16:17 UTC] wez@php.net
Sounds like expected behaviour in safe_mode.
 [2010-12-20 11:53 UTC] jani@php.net
-Package: Tidy +Package: Safe Mode/open_basedir
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 10:01:29 2024 UTC