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.3.3RC1~253 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a5d361e3eaed7962bea787a45ca88bbd7551c1b9;p=php Fixed #48361 (SplFileInfo::getPathName() should return the parent --- diff --git a/NEWS b/NEWS index b3a228fd82..260bbea5b3 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index e9eb9bad54..7c4cb95179 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=== +