Skip to content

Conversation

@cmb69
Copy link
Member

@cmb69 cmb69 commented Jul 29, 2016

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?

For consistency with substr() and mb_substr(), iconv_substr() should return
an empty string instead of FALSE, when $offset == iconv_strlen($str).
@cmb69
Copy link
Member Author

cmb69 commented Jul 29, 2016

The failing checks appear to be unrelated to this patch.

@nikic
Copy link
Member

nikic commented Jul 29, 2016

Given the unexpectedly large fallout the change for substr had, I don't think it should go into 5.6 (though iconv_substr is of course used much less). One of 7.0 (because substr changed here) or 7.1 (the conservative choice) sounds fine to me.

@cmb69
Copy link
Member Author

cmb69 commented Aug 24, 2016

@weltling Is it okay to treat this issue as bug and fix it in PHP 7.0+, or do you think we should go with PHP 7.1+ only?

@weltling
Copy link
Contributor

@cmb69 I see some usage here and there, but couldn't find issues in OSS apps regarding this change so far. And iconv_substr is indeed used rarely, so I don't really see what would prevent to give this change a try in 7.0.

Thanks.

@cmb69
Copy link
Member Author

cmb69 commented Aug 29, 2016

@weltling Thanks for having a look at this issue. I'm going to merge into 7.0+.

@php-pulls php-pulls merged commit a837b2f into php:PHP-7.0 Aug 29, 2016
@cmb69 cmb69 deleted the iconv-substr branch August 29, 2016 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants