]> granicus.if.org Git - php/commitdiff
Revert SplFileInfo BC break while keeping fix for assertion removal
authorAnthony Ferrara <ircmaxell@gmail.com>
Mon, 13 Jul 2015 17:27:06 +0000 (13:27 -0400)
committerAnthony Ferrara <ircmaxell@gmail.com>
Mon, 13 Jul 2015 17:27:06 +0000 (13:27 -0400)
This reverts the minor bc-break where .test would return an empty extension. This is different from 5.x's behavior.

In 7, it would result in an assertion failure crash. The fix for the removal of this assertion is kept, keeping BC with 5.x.

ext/spl/spl_directory.c
ext/spl/tests/spl_fileinfo_getextension_leadingdot.phpt

index 0ee1ae0530c92c48c3300ff6fbcb81d16a09ac67..eaaf609501b474577310a2fabccaf88e3576620d 100644 (file)
@@ -939,9 +939,7 @@ SPL_METHOD(SplFileInfo, getExtension)
        ret = php_basename(fname, flen, NULL, 0);
 
        p = zend_memrchr(ZSTR_VAL(ret), '.', ZSTR_LEN(ret));
-       if (p && p > ZSTR_VAL(ret)) {
-               /* Check for the string length, incase the only '.' is the
-                * first character of the string */
+       if (p) {
                idx = (int)(p - ZSTR_VAL(ret));
                RETVAL_STRINGL(ZSTR_VAL(ret) + idx + 1, ZSTR_LEN(ret) - idx - 1);
                zend_string_release(ret);
index 0ade304a35ba31fed04891e30d7d83f27e0b5740..7b2be18900aa68b8edd8cfb5171372306c0c1290 100644 (file)
@@ -10,4 +10,4 @@ var_dump($fileInfo->getExtension());
 unlink($file);
 ?>
 --EXPECT--
-string(0) ""
\ No newline at end of file
+string(4) "test"