diff --git a/hphp/runtime/ext/ext_file.cpp b/hphp/runtime/ext/ext_file.cpp index 9b3e4e7f2..a49950da5 100644 --- a/hphp/runtime/ext/ext_file.cpp +++ b/hphp/runtime/ext/ext_file.cpp @@ -856,12 +856,18 @@ static const StaticString s_filename("filename"); Variant f_pathinfo(CStrRef path, int opt /* = 15 */) { ArrayInit ret(4); + if (opt == 0) { + return empty_string; + } + if ((opt & PHP_PATHINFO_DIRNAME) == PHP_PATHINFO_DIRNAME) { String dirname = f_dirname(path); if (opt == PHP_PATHINFO_DIRNAME) { return dirname; } - ret.set(s_dirname, dirname); + if (!dirname.equal(empty_string)) { + ret.set(s_dirname, dirname); + } } String basename = f_basename(path); @@ -874,19 +880,19 @@ Variant f_pathinfo(CStrRef path, int opt /* = 15 */) { if ((opt & PHP_PATHINFO_EXTENSION) == PHP_PATHINFO_EXTENSION) { int pos = basename.rfind('.'); - String extension; + String extension(empty_string); if (pos >= 0) { extension = basename.substr(pos + 1); + ret.set(s_extension, extension); } if (opt == PHP_PATHINFO_EXTENSION) { return extension; } - ret.set(s_extension, extension); } if ((opt & PHP_PATHINFO_FILENAME) == PHP_PATHINFO_FILENAME) { int pos = basename.rfind('.'); - String filename; + String filename(empty_string); if (pos >= 0) { filename = basename.substr(0, pos); } else { diff --git a/hphp/test/zend/bad/ext-standard-file/pathinfo_basic.php b/hphp/test/zend/good/ext-standard-file/pathinfo_basic.php similarity index 100% rename from hphp/test/zend/bad/ext-standard-file/pathinfo_basic.php rename to hphp/test/zend/good/ext-standard-file/pathinfo_basic.php diff --git a/hphp/test/zend/bad/ext-standard-file/pathinfo_basic.php.expectf b/hphp/test/zend/good/ext-standard-file/pathinfo_basic.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-standard-file/pathinfo_basic.php.expectf rename to hphp/test/zend/good/ext-standard-file/pathinfo_basic.php.expectf diff --git a/hphp/test/zend/bad/ext-standard-file/pathinfo_basic1.php b/hphp/test/zend/good/ext-standard-file/pathinfo_basic1.php similarity index 100% rename from hphp/test/zend/bad/ext-standard-file/pathinfo_basic1.php rename to hphp/test/zend/good/ext-standard-file/pathinfo_basic1.php diff --git a/hphp/test/zend/bad/ext-standard-file/pathinfo_basic1.php.expectf b/hphp/test/zend/good/ext-standard-file/pathinfo_basic1.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-standard-file/pathinfo_basic1.php.expectf rename to hphp/test/zend/good/ext-standard-file/pathinfo_basic1.php.expectf diff --git a/hphp/test/zend/bad/ext-standard-file/pathinfo_basic2.php b/hphp/test/zend/good/ext-standard-file/pathinfo_basic2.php similarity index 100% rename from hphp/test/zend/bad/ext-standard-file/pathinfo_basic2.php rename to hphp/test/zend/good/ext-standard-file/pathinfo_basic2.php diff --git a/hphp/test/zend/bad/ext-standard-file/pathinfo_basic2.php.expectf b/hphp/test/zend/good/ext-standard-file/pathinfo_basic2.php.expectf similarity index 100% rename from hphp/test/zend/bad/ext-standard-file/pathinfo_basic2.php.expectf rename to hphp/test/zend/good/ext-standard-file/pathinfo_basic2.php.expectf