From:             RQuadling at GMail dot com
Operating system: Windows XP SP3
PHP version:      5.3SVN-2010-01-04 (snap)
PHP Bug Type:     Directory function related
Bug description:  Junctions over a share fail

Description:
------------
realpath() returns false for files inside junctions inside a share 
accessed using a relative path.

Ok. I _did_ say this was an edge case.

The code below is an batch script utilising Windows NET SHARE and NET 
MAP commands to create a drive J: mapped to C:\RAQ_Share and the 
JUNCTION program from System Internals to create a junction in that 
share. 

The last few lines relate specifically to PHP.

Essentially absolute paths are realpath()-able just fine, but relative 
paths are not.





Reproduce code:
---------------
@ECHO OFF
ECHO Create Original directory and file.
MD C:\RAQ_Orig
ECHO This is the file. > C:\RAQ_Orig\File.txt
ECHO.

ECHO Create share
MD C:\RAQ_Share
NET SHARE RAQ_Shared=C:\RAQ_Share /UNLIMITED
ECHO.

ECHO Map share
@NET USE J: /D > NUL
NET USE J: \\%COMPUTERNAME%\RAQ_Shared
ECHO.

ECHO Create junction
MD J:\RAQ_Junc
JUNCTION J:\RAQ_Junc C:\RAQ_Orig
ECHO.

ECHO Show the folders.
DIR \RAQ*
ECHO.

ECHO See contents of junction
DIR J:\RAQ_Junc\File.txt
ECHO.

ECHO Use PHP to report realpaths
PHP -v
PHP -n -r "var_dump(realpath('J:/RAQ_Junc/File.txt'));"
CD /D J:\
PHP -n -r "var_dump(realpath('/RAQ_Junc/File.txt'));"
CD \RAQ_Junc
PHP -n -r "var_dump(realpath('./File.txt'));"


Expected result:
----------------
Create Original directory and file.

Create share
RAQ_Shared was shared successfully.


Drop and map share
J: was deleted successfully.

The command completed successfully.


Create junction

Junction v1.05 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2007 Mark Russinovich
Systems Internals - http://www.sysinternals.com

Created: J:\RAQ_Junc
Targetted at: C:\RAQ_Orig

Show the folders.
 Volume in drive C has no label.
 Volume Serial Number is 1044-5992

 Directory of C:\

2010/01/04  17:47    <DIR>          RAQ_Orig
2010/01/04  17:47    <DIR>          RAQ_Share
               0 File(s)              0 bytes
               2 Dir(s)  11,663,155,200 bytes free

See contents of junction
 Volume in drive J has no label.
 Volume Serial Number is 1044-5992

 Directory of J:\RAQ_Junc

2010/01/04  17:47                20 File.txt
               1 File(s)             20 bytes
               0 Dir(s)  11,663,155,200 bytes free

Use PHP to report realpaths
PHP 5.3.3-dev (cli) (built: Jan  4 2010 12:59:42)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
string(20) "C:\RAQ_Orig\File.txt"
string(20) "C:\RAQ_Orig\File.txt"
string(20) "C:\RAQ_Orig\File.txt"


Actual result:
--------------
Create Original directory and file.

Create share
RAQ_Shared was shared successfully.


Drop and map share
J: was deleted successfully.

The command completed successfully.


Create junction

Junction v1.05 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2007 Mark Russinovich
Systems Internals - http://www.sysinternals.com

Created: J:\RAQ_Junc
Targetted at: C:\RAQ_Orig

Show the folders.
 Volume in drive C has no label.
 Volume Serial Number is 1044-5992

 Directory of C:\

2010/01/04  17:47    <DIR>          RAQ_Orig
2010/01/04  17:47    <DIR>          RAQ_Share
               0 File(s)              0 bytes
               2 Dir(s)  11,663,155,200 bytes free

See contents of junction
 Volume in drive J has no label.
 Volume Serial Number is 1044-5992

 Directory of J:\RAQ_Junc

2010/01/04  17:47                20 File.txt
               1 File(s)             20 bytes
               0 Dir(s)  11,663,155,200 bytes free

Use PHP to report realpaths
PHP 5.3.3-dev (cli) (built: Jan  4 2010 12:59:42)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
string(20) "C:\RAQ_Orig\File.txt"
string(20) "C:\RAQ_Orig\File.txt"
bool(false)

-- 
Edit bug report at http://bugs.php.net/?id=50659&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=50659&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=50659&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=50659&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=50659&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50659&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=50659&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=50659&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=50659&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=50659&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=50659&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=50659&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=50659&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=50659&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=50659&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50659&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50659&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=50659&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=50659&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=50659&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=50659&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=50659&r=mysqlcfg

Reply via email to