From 21686f1b3070bfb8a535ec717d9b69a094fe651a Mon Sep 17 00:00:00 2001 From: Anthony Ferrara Date: Mon, 13 Jul 2015 13:27:06 -0400 Subject: [PATCH] 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. --- ext/spl/spl_directory.c | 4 +--- ext/spl/tests/spl_fileinfo_getextension_leadingdot.phpt | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) 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" -- 2.50.1