From: Anthony Ferrara Date: Mon, 13 Jul 2015 17:27:06 +0000 (-0400) Subject: Revert SplFileInfo BC break while keeping fix for assertion removal X-Git-Tag: php-7.1.1RC1~35^2~8^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21686f1b3070bfb8a535ec717d9b69a094fe651a;p=php Revert SplFileInfo BC break while keeping fix for assertion removal 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. --- diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 0ee1ae0530..eaaf609501 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -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); diff --git a/ext/spl/tests/spl_fileinfo_getextension_leadingdot.phpt b/ext/spl/tests/spl_fileinfo_getextension_leadingdot.phpt index 0ade304a35..7b2be18900 100644 --- a/ext/spl/tests/spl_fileinfo_getextension_leadingdot.phpt +++ b/ext/spl/tests/spl_fileinfo_getextension_leadingdot.phpt @@ -10,4 +10,4 @@ var_dump($fileInfo->getExtension()); unlink($file); ?> --EXPECT-- -string(0) "" \ No newline at end of file +string(4) "test"