From: Etienne Kneuss Date: Tue, 27 Apr 2010 08:56:01 +0000 (+0000) Subject: Fixed #48361 (SplFileInfo::getPathName() should return the parent X-Git-Tag: php-5.4.0alpha1~191^2~1639 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07a6d662762f46eb2f10c03c1f09656e91d56fec;p=php Fixed #48361 (SplFileInfo::getPathName() should return the parent --- diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index b7fa311c65..23044122a9 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -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); } } diff --git a/ext/spl/tests/bug48361.phpt b/ext/spl/tests/bug48361.phpt new file mode 100644 index 0000000000..44b05abba1 --- /dev/null +++ b/ext/spl/tests/bug48361.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: Bug #48361 SpleFileInfo::getPathName should return the dirname's path +--FILE-- +getRealPath()); +var_dump($info->getPathInfo()->getRealPath()); +?> +===DONE=== +--EXPECTF-- +string(%d) "%stests%sbug48361.php" +string(%d) "%stests" +===DONE=== +