Fixed #48361 (SplFileInfo::getPathName() should return the parent

This commit is contained in:
Etienne Kneuss 2010-04-27 08:56:01 +00:00
parent 8525f7bb02
commit a5d361e3ea
3 changed files with 20 additions and 1 deletions

2
NEWS
View File

@ -106,6 +106,8 @@ PHP NEWS
- Fixed bug #48983 (DomDocument : saveHTMLFile wrong charset). (Rob)
- Fixed bug #48902 (Timezone database fallback map is outdated). (Derick)
- Fixed bug #48781 (Cyclical garbage collector memory leak). (Dmitry)
- Fixed bug #48361 (SplFileInfo::getPathInfo should return the
parent dir). (Etienne)
- Fixed bug #46111 (Some timezone identifiers can not be parsed). (Derick)
- Fixed bug #35673 (formatOutput does not work with saveHTML). (Rob)

View File

@ -1187,7 +1187,10 @@ SPL_METHOD(SplFileInfo, getPathInfo)
int path_len;
char *path = spl_filesystem_object_get_pathname(intern, &path_len TSRMLS_CC);
if (path) {
spl_filesystem_object_create_info(intern, path, path_len, 1, ce, return_value TSRMLS_CC);
char *dpath = estrndup(path, path_len);
path_len = php_dirname(dpath, path_len);
spl_filesystem_object_create_info(intern, dpath, path_len, 1, ce, return_value TSRMLS_CC);
efree(dpath);
}
}

View File

@ -0,0 +1,14 @@
--TEST--
SPL: Bug #48361 SpleFileInfo::getPathName should return the dirname's path
--FILE--
<?php
$info = new SplFileInfo(__FILE__);
var_dump($info->getRealPath());
var_dump($info->getPathInfo()->getRealPath());
?>
===DONE===
--EXPECTF--
string(%d) "%stests%sbug48361.php"
string(%d) "%stests"
===DONE===