php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46629 is_dir returns incorrect result
Submitted: 2008-11-20 11:26 UTC Modified: 2008-12-28 22:55 UTC
From: j-e dot zwar at bigpond dot net dot au Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 5.2.6 OS: win32 only
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: j-e dot zwar at bigpond dot net dot au
New email:
PHP Version: OS:

 

 [2008-11-20 11:26 UTC] j-e dot zwar at bigpond dot net dot au
Description:
------------
PHP function is_dir does not recognise some of the directories in my PC directory structure.
Environment is:
. Dell Core 2 Duo PC
. Windows XP Pro SP3
. PHP version 5.2.6
. IIS version 5.1
. MySQL version 5.0.51b-community-nt
. Dreamweaver MX2004 version 7 as the "text editor"
. Internet Explorer version 6.0.2900
. sendmail.exe
All running on the Dell PC - i.e., all executions are via 'localhost'


Reproduce code:
---------------
$dir1 = "C:/AAImages/";
$dir2 = "C:/Documents and Settings/";
$dir3 = "C:/Documents and Settings/Fred & Ginger/";
$dir4 = "C:/Documents and Settings/Fred & Ginger/My Documents/";
$dir5 = "C:/Documents and Settings/Fred & Ginger/My Documents/AC Images Test/";

var_dump (is_dir($dir1));  // returns true (correctly)
var_dump (is_dir($dir2));  // returns true (correctly)
var_dump (is_dir($dir3));  // returns true (correctly)
var_dump (is_dir($dir4));  // returns false (incorrectly)
var_dump (is_dir($dir5));  // returns false (incorrectly)

But all these directories do exist on my PC and I have checked the spelling carefully. Permissions seem to be OK as I can upload files from the lower level directories via an HTML form OK.


Expected result:
----------------
var_dump (is_dir($dir4)) and var_dump(is_dir($dir5)) should both return TRUE, i.e., all of the 5 var_dumps should return TRUE.

Have tried it inversely and the same error is apparent - i.e., tried var_dump(!is_dir($dir4)) etc.  With the 'not' tests I get false, false, false, true and true.

Have also tried it with double backslashes in the directory names instead of the single forward slashes - same error apparent.

Have also tried it without the trailing forward slash at the end of each directory name with the same erroneous result.

Actual result:
--------------
var_dump (is_dir($dir1));  // returns true (correctly)
var_dump (is_dir($dir2));  // returns true (correctly)
var_dump (is_dir($dir3));  // returns true (correctly)
var_dump (is_dir($dir4));  // returns false (incorrectly)
var_dump (is_dir($dir5));  // returns false (incorrectly)

Any help/advice will be very much appreciated.
Thank you in anticipation.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-20 19:19 UTC] jani@php.net
Check permissions.
 [2008-11-22 22:40 UTC] j-e dot zwar at bigpond dot net dot au
Thanks for the advice.  I changed the permissions and now the lowest level returns TRUE but not the "My Documents" level??

I.e., "C:/Documents and Settings/Fred & Ginger/My Documents/AC Images
Test" returns TRUE but
"C:/Documents and Settings/Fred & Ginger/My Documents" still returns FALSE.

I right-clicked on the directory in Windows Explorer and within the Security tag entered IUSR_COMPUTERNAME (with my computer name) and then ticked the 'full control' box.

Any other advice will be appreciated.
 [2008-11-23 22:53 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2008-11-24 22:39 UTC] j-e dot zwar at bigpond dot net dot au
Thank you for your recommendation.
I tried to install PHP 5.3 (Windows x86 VC9 (thread safe)) installer from windows.php.net/snapshots/ but get a setup error "there is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor".
I did install the Microsoft 2008 C++ runtime first.
 [2008-11-24 22:58 UTC] pajoye@php.net
Not sure what's wrong with the installer on your box, but you can fetch a zip, uncompress it and run your test script from the command line. Please try it.
 [2008-11-25 12:49 UTC] j-e dot zwar at bigpond dot net dot au
Thanks, I will try to do this.  But I will need some time as I've not used PHP from a command line before and thus will need to research how to do this.  Thanks again for your suggestion.  So far I have downloaded the zip "PHP 5.3 Windows x86 VC9 (thread safe)) and then unzipped it to a new directory C:/PHP5.3.
 [2008-11-25 13:19 UTC] j-e dot zwar at bigpond dot net dot au
Progress report and unexpected result.
Have not yet gotten the 5.3 version to work but I did find out how to run a script from the windows command line.
Using my current 5.2.6 php, and executing the directory test script from the command line, all 5 tests return true, but when I execute it in my browser (IE6), test 4 returns false!
Seems like something in the browser is causing test 4 (C:\Documents and Settings\Fred & Ginger\My Documents) to return false.
Can you offer any suggestions?
Thanks again in anticipation.
 [2008-11-26 08:33 UTC] j-e dot zwar at bigpond dot net dot au
Have run some more tests.  FYI I get the same anomaly when I run the script in a Mozilla/Firefox browser, so it appears something to do with browsers on my PC rather than with IE6 itself.

Again, any advice and suggestions will be most appreciated.
 [2008-12-28 20:21 UTC] felipe@php.net
Probably the version on command line is an newer version, and on browser is another version used by Apache or other server.
 [2008-12-28 22:45 UTC] j-e dot zwar at bigpond dot net dot au
Thanks for the suggestion to check the versions.  I'm confident that it is the same version of PHP which is running when I try from the command line or from IE6/IIS.

PHP -v from the command line says that it is version 5.2.6 which is the same version and build date that I get when executing a script with PHPINFO from IE6 and Mozilla/Firefox.

So executing a test-directory script from the command line gives me boolean trues for each directory tested, but when executing the SAME script from a browser, I get one false with the others true.
 [2008-12-28 22:55 UTC] pajoye@php.net
The browser has nothing to do with this problem. The script is run by the IIS server.

is_dir function works as expected, check the permissions (all!), the error log or enable display errors and error reporting set to all.

Please post further questions can go to the php-general mailing list.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 11:01:28 2024 UTC