|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51952 __FILE__ and dirname() are returning wrong pathes when working with junctions
Submitted: 2010-05-31 01:39 UTC Modified: 2010-05-31 02:36 UTC
From: whistl0r+phpbug at googlemail dot com Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 5.2.13 OS: Windows Vista/7
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.
Block user comment
Status: Assign to:
Bug Type:
From: whistl0r+phpbug at googlemail dot com
New email:
PHP Version: OS:


 [2010-05-31 01:39 UTC] whistl0r+phpbug at googlemail dot com
Consister the following setup:

You keep your source code in "C:\Repositories\\trunk".
You just point your DOCUMENT_ROOT to that folder via symlink/junction:

DOCUMENT_ROOT "C:\Sites\\htdocs"

 Volume in drive D is System
 Volume Serial Number is E49D-A2E7

 Directory of C:\Sites\

2010-05-31  01:08    <DIR>          .
2010-05-31  01:08    <DIR>          ..
2010-05-31  01:08    <JUNCTION>     htdocs [C:\Repositories\\trunk]

You now run the script "C:\Sites\\htdocs\test.php".

Test script:
echo 'File: ' . __FILE__ . PHP_EOL;
echo 'Dir: ' . dirname(__FILE__) . PHP_EOL;

Expected result:
File: C:\Repositories\\trunk\test.php
Dir: C:\Repositories\\trunk

Actual result:
File: C:\Sites\\htdocs\test.php
Dir: C:\Sites\\htdocs


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-31 01:44 UTC] whistl0r+phpbug at googlemail dot com
I found this inconsistent behavior, after upgrading to PHP 5.3, because a required 
once call (required_once realpath(dirname(__FILE__) . '/../configs/main.php');) 

It failed because PHP 5.3 resolves the symlinks.

I checked the documentation and it says that this is the wanted behavior.

So it seems like, because it nothing new in PHP 5.3, that it must be a bug in PHP 
 [2010-05-31 02:36 UTC]
-Status: Open +Status: Bogus
 [2010-05-31 02:36 UTC]
Windows was the only platform where it did not resolve it. The reason was that 5.2 did not support symlink on windows (or junctions) resolutions.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 07:01:29 2024 UTC