Bug #72367 [Opn]: Relative Drive:path incorrectly assumed to be Drive:/path
| From: | RQuadling at GMail dot com | Date: | Fri, 10 Jun 2016 12:05:59 +0000 |
| Subject: | Bug #72367 [Opn]: Relative Drive:path incorrectly assumed to be Drive:/path | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-201518@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72367&edit=1
ID: 72367
User updated by: RQuadling at GMail dot com
Reported by: RQuadling at GMail dot com
Summary: Relative Drive:path incorrectly assumed to be
Drive:/path
Status: Open
Type: Bug
Package: *Directory/Filesystem functions
Operating System: Windows
PHP Version: 5.6.22
Block user comment: N
Private report: N
New Comment:
Typo in my initial report ...
Whilst this is similar in some aspects to previously reported bugs related to realpath(), the issue
is that the constants __FILE__ and __DIR__ are INCORRECT, thus making them useless.
Previous Comments:
------------------------------------------------------------------------
[2016-06-09 09:38:33] RQuadling at GMail dot com
Description:
------------
If you use a relative path to a file from Windows command line, PHP interprets the supplied location
as a root.
The test script below requires a Windows setup with 2 drives (C and D). The script is a batch script
that creates the test script and cleans up after itself.
Whilst this is similar in some aspects to previously reported bugs related to realpath(), the issue
is that the constants __FILE__ and __DIR__ are correct, thus making them useless.
OOI, using the absolute path for the PHP script (C:\PHP56\PHP D:\ReaL\PaTH\BuG\TeSTBuG.php),
produces the correct results.
Test script:
---------------
@ECHO OFF
REM Make directories for testing.
MD C:\Test\Real\PaTH\BuG
MD D:\ReaL\PaTH\BuG
REM Make test PHP script.
ECHO ^<?php > D:\ReaL\PaTH\BuG\TeSTBuG.php
ECHO var_export([PHP_VERSION, __FILE__, __DIR__, getcwd(), realpath(__FILE__), realpath(__DIR__),
realpath(getcwd()), $argv]);>> D:\ReaL\PaTH\BuG\TeSTBuG.php
REM Make sure drives are in their directories.
CD /D D:\ReaL\PaTH\BuG
CD /D C:\Test\Real\PaTH\BuG
REM Call PHP using relative paths.
C:\PHP56\PHP D:TeSTBuG.php
REM Clean-up
DEL D:\ReaL\PaTH\BuG\TeSTBuG.php
CD /D D:\
CD /D C:\
RD C:\Test\Real\PaTH\BuG
RD D:\ReaL\PaTH\BuG
Expected result:
----------------
array (
0 => '5.6.20',
1 => 'D:\\ReaL\\PaTH\\BuG\\TeSTBuG.php',
2 => 'D:\\ReaL\\PaTH\\BuG',
3 => 'C:\\Test\\Real\\PaTH\\BuG',
4 => D:\\ReaL\\PaTH\\BuG\\TeSTBuG.php,
5 => 'D:\\ReaL\\PaTH\\BuG',
6 => 'C:\\Test\\Real\\PaTH\\BuG',
7 =>
array (
0 => 'D:TeSTBuG.php',
),
)
Actual result:
--------------
array (
0 => '5.6.20',
1 => 'D:\\TeSTBuG.php',
2 => 'D:\\',
3 => 'C:\\Test\\Real\\PaTH\\BuG',
4 => false,
5 => 'D:\\',
6 => 'C:\\Test\\Real\\PaTH\\BuG',
7 =>
array (
0 => 'D:TeSTBuG.php',
),
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72367&edit=1