Fix #72320: iconv_substr returns false for empty strings #2043
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For consistency with substr() and mb_substr(), iconv_substr() should return
an empty string instead of FALSE, when $offset == iconv_strlen($str).
In my opinion, the question is not whether to apply this patch, but rather against which PHP version. According to the docs ("If str is shorter than offset characters long, FALSE will be returned.") this is a bug, and so should be applied against PHP 5.6+. However, this change causes a BC break, so it might best be applied to master only. Then again, the respective behavior of substr() has been changed as of PHP 7, so a reasonable compromise would be to apply the fix against PHP 7.0 or maybe PHP 7.1.
Thoughts?