php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #64927 realpath() still returns current path on Null/false argument
Submitted: 2013-05-27 07:42 UTC Modified: 2015-04-27 04:59 UTC
From: myustc at 163 dot com Assigned: sobak (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.3.25 OS: Mac OS X 10.6.8
Private report: No CVE-ID: None
 [2013-05-27 07:42 UTC] myustc at 163 dot com
Description:
------------
---
From manual page: http://www.php.net/function.realpath#refsect1-function.realpath-changelog
---

I'm using PHP 5.3.15 (cli) (built: Jul 31 2012 18:42:11).
When I'm tracking a bug in Yii, I realized that it's the issue of php function realpath().
the reproducing is very easy, just run this in console:

php -r "var_dump(realpath(false), realpath(null), realpath(''));"



Test script:
---------------
<?php

var_dump(realpath(false));
var_dump(realpath(null));
var_dump(realpath(''));


Expected result:
----------------
I should see output as below:

bool(false)
bool(false)
bool(false)


Actual result:
--------------
output:(the actual path depends)

string(22) "/Users/yaowenh/phpunit"
string(22) "/Users/yaowenh/phpunit"
string(22) "/Users/yaowenh/phpunit"


Patches

changelog (last revision 2015-04-23 21:13 UTC by cmb@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-27 07:48 UTC] earlchaos at gmail dot com
I don't see the problem here?

From the manual:

path

    The path being checked.

        Note:

        Whilst a path must be supplied, the value can be blank or NULL In these cases, the value is interpreted as the current directory.
 [2013-05-28 07:12 UTC] myustc at 163 dot com
Sorry, I meant the Changelog part:
-------------------

5.0.0	 Prior to this release, a blank or NULL path would cause realpath() to return the directory name of the script.

-------------------
which sounds to me as if such behavior was removed since 5.0.0. Correct me if I'm wrong...
 [2013-05-29 18:47 UTC] Sjon at hortensius dot net
It seems that Changelog notice is incorrect; see http://3v4l.org/MJUQe The only 
difference is that since 5.2 the cwd is returned
 [2015-04-23 21:13 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2015-04-23 21:13 UTC] cmb@php.net
The PHP 5.0.0 changelog entry has been removed in the meantime. However, the behavioral change in PHP 5.2.1 pointed out by Sjon is not yet documented.
 [2015-04-23 21:13 UTC] cmb@php.net
The following patch has been added/updated:

Patch Name: changelog
Revision:   1429823637
URL:        https://bugs.php.net/patch-display.php?bug=64927&patch=changelog&revision=1429823637
 [2015-04-27 04:58 UTC] sobak@php.net
Automatic comment from SVN on behalf of sobak
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=336672
Log: Apply patch by Christoph Michael Becker (closes bug #64927)
 [2015-04-27 04:59 UTC] sobak@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: sobak
 [2015-04-27 04:59 UTC] sobak@php.net
Thanks, Christoph! Closed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 07:01:30 2024 UTC