[Bug 302786] [NEW] PHP5 Realpath function
Launchpad Bug Tracker
302786 at bugs.launchpad.net
Fri Feb 20 14:58:45 GMT 2009
You have been subscribed to a public bug:
Package: php5
version: 5.2.4-2ubuntu5.3
Distributor ID: Ubuntu
Description: Ubuntu 8.04.1
Release: 8.04
Codename: hardy
PHP function "realpath()" does not function according to spec.
According to PHP.net's documentation:
==================
realpath — Returns canonicalized absolute pathname
Returns the canonicalized absolute pathname on success. The resulting
path will have no symbolic link, '/./' or '/../' components.
realpath() returns FALSE on failure, e.g. if the file does not exist.
==================
http://uk2.php.net/realpath
The problem is that in this version of PHP (5.2.4-2ubuntu5.3), realpath fails to return FALSE if the file does not exist.
ie.
Code:
$a = "/this/file/does/not/exist";
var_dump ( realpath ( $a ) );
Result:
string(25) "/this/file/does/not/exist"
Result should be:
bool(false)
Work around is to check if file exists:
$a = "/this/file/does/not/exist";
var_dump ( realpath ( $a ) );
if ( true === file_exists ( $a ) ) {
$result = realpath ( $a );
} else {
$result = false;
}
var_dump ( $result );
But this is obviously a bug, which may cause many hard-to-trace bugs in many frameworks, as they assume realpath works as it should according to PHP.net's documentation. Therefore, I would probably escalate it as a serious bug.
** Affects: php5 (Ubuntu)
Importance: Undecided
Status: New
** Tags: 8.04 hardy php5 realpath
--
PHP5 Realpath function
https://bugs.launchpad.net/bugs/302786
You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to php5 in ubuntu.
More information about the Ubuntu-server-bugs
mailing list