From 07a6d662762f46eb2f10c03c1f09656e91d56fec Mon Sep 17 00:00:00 2001 From: Etienne Kneuss Date: Tue, 27 Apr 2010 08:56:01 +0000 Subject: [PATCH] Fixed #48361 (SplFileInfo::getPathName() should return the parent --- ext/spl/spl_directory.c | 5 ++++- ext/spl/tests/bug48361.phpt | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 ext/spl/tests/bug48361.phpt 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=== + -- 2.50.0