php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43248 backward compatibility break in realpath()
Submitted: 2007-11-11 19:09 UTC Modified: 2007-11-13 09:47 UTC
From: carsten_sttgt at gmx dot de Assigned: dmitry (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.2.5 OS: Windows_NT
Private report: No CVE-ID: None
 [2007-11-11 19:09 UTC] carsten_sttgt at gmx dot de
Description:
------------
Hello,

regarding Bug #42778, I think should give a better explanation, why there was a break in backward compatibility in the function realpath() on windows between PHP 5.2.3 and 5.2.4, without any information in the manual or changelog.

Additional, in the manual you can read:
| The resulting path will have no symbolic link,
| '/./' or '/../' components.

A "/./" as last component in a path, is the same as "/" as last component. And thus the last "/" must be removed.

As you can see, the results with PHP 4.4.7(Win), PHP <=5.2.3(Win) and PHP 5.2.5(FreeBSD) are the same and like descriped in the manual.

Only with PHP >=5.2.3(Win) you have a different result.

The DirectoryIterator also have the same behaviour with all OS and versions.

(BTW: With Perl or VBS I have also no trailing slash on Windows)

Regards,
Carsten

BTW: You should not forget:
For an PHP programer it's necessary, to have the same results in PHP functions between PHP versions and operating systems. (especially without informations)


Reproduce code:
---------------
Testscripts are executed with (in the given dirs):
$ .\php -n test.php

Testscript 1 in C:\php5
<?php
  echo realpath('extras\\mibs\\');
?>

Testscript 2 in C:\php4
<?php
  echo realpath('extras\\mibs\\');
?>


Testscript 3 in C:\php5
<?php
  $dir = new DirectoryIterator('extras\\mibs\\');
  echo $dir->getRealPath();
?>


Testscripts are executed with (in the given dirs):
$ ./php -n test.php

Testscript 4 in /usr/local/bin (with FreeBSD)
<?php
  echo realpath('../include/');
?>

Testscript 5 in /usr/local/bin (with FreeBSD)
<?php
  $dir = new DirectoryIterator('../include/');
  echo $dir->getRealPath();
?>


Expected result:
----------------
on Windows with PHP5:
C:\php5\extras\mibs

on Windows with PHP4:
C:\php4\extras\mibs

on FreeBSD:
/usr/local/include



Actual result:
--------------
Testscript 1 with PHP 5.2.3:
C:\php5\extras\mibs

Testscript 2 with PHP 4.4.7 (Win):
C:\php4\extras\mibs

Testscript 1 with PHP 5.2.4 (Win):
C:\php5\extras\mibs\

Testscript 1 with PHP 5.2.5 (Win):
C:\php5\extras\mibs\

Testscript 3 with PHP 5.2.5 (Win):
C:\php5\extras\mibs

Testscript 4 with PHP 5.2.5 (FreeBSD):
/usr/local/include

Testscript 5 with PHP 5.2.5 (FreeBSD):
/usr/local/include


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-13 09:47 UTC] dmitry@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 04:01:31 2024 UTC