]> 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)
ext/spl/spl_directory.c
ext/spl/tests/bug48361.phpt [new file with mode: 0644]

index b7fa311c6529ec1d55be8f83feef03af7333287f..23044122a97c38881933f30e60ed0466125738d6 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===
+