]> granicus.if.org Git - php/commitdiff
Fixed #48361 (SplFileInfo::getPathName() should return the parent
authorEtienne Kneuss <colder@php.net>
Tue, 27 Apr 2010 08:56:01 +0000 (08:56 +0000)
committerEtienne Kneuss <colder@php.net>
Tue, 27 Apr 2010 08:56:01 +0000 (08:56 +0000)
NEWS
ext/spl/spl_directory.c
ext/spl/tests/bug48361.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index b3a228fd82b33bba4f59fb91783c79469cf370aa..260bbea5b3bc6572ce4ee6eecf35abb2510e76d7 100644 (file)
--- 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)
 
index e9eb9bad5425739f9adb9f76517a2ba1edc9220d..7c4cb9517904bef3bed2feb506ba25a2f6495600 100755 (executable)
@@ -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 (file)
index 0000000..44b05ab
--- /dev/null
@@ -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===
+