Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Deprecated: idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated in /wire/core/Sanitizer.php:550 #616

Closed
adrianbj opened this issue Jun 6, 2018 · 4 comments

Comments

@adrianbj
Copy link

adrianbj commented Jun 6, 2018

Short description of the issue

Getting the title error in php 7.2

ryancramerdesign added a commit to processwire/processwire that referenced this issue Jun 15, 2018
…g deprecation notices for default arguments of idn_to_utf8() and idn_to_ascii(). The deprecation change and new defaults for next major PHP version does not appear to affect our usage after several tests, so opted to suppress these notices.
@ryancramerdesign
Copy link
Member

Thanks, I've pushed a fix.

@adrianbj
Copy link
Author

Hey @ryancramerdesign - is that really the best solution? Maybe I am missing something, but it's not the idn_to_utf8() function that is deprecated, but rather you need to explicitly set the 3rd argument - the $variant.

Have a read here: roundcube/roundcubemail#6075

@ryancramerdesign
Copy link
Member

Yeah I originally coded it that way, but it left me having to do PHP version detection, determine whether the define was available (since it was added in PHP 5.4 apparently). Messy conditionals for a simple function call. Then it was requiring that the $options and $variant arguments be passed by reference, meaning more code. Then PhpStorm had some other inexplicable complaint about the function call arguments, which is probably a PhpStorm bug, but I don't want to see that red flag every time I edit Sanitizer. Then I read that some people are seeing issues after changing the $variant argument to the new flag, because the PHP version supports it, but the underlying system library doesn't (apparently an issue on some web hosts).

I did some research on why they are throwing deprecated notices for the default arguments on this function, which demands an explanation. It turns out they are changing the default $variant argument to the newly suggested one in the next major version of PHP. The deprecation notice is there to let people know the defaults are changing (and old default being dropped as an option), as there may be cases where it matters, so throwing the notice actually makes sense despite being a bit odd. I tested with what will be the new default $variant in the next major PHP version, and found it produced identical results for our use cases as the current defaults. I concluded that accepting the default arguments for these functions, regardless of PHP version, seems to be a safer bet, and doesn't require a bunch of extra messy support code, so this is one of the rare cases where the suppression operator seemed to make more sense. Though please let me know if you find PHP 7.2 is bypassing that suppression operator.

@adrianbj
Copy link
Author

Thanks for the detailed explanation Ryan - I should have realized that you had looked into it properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants