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

idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated #163

Open
aaronpk opened this issue Feb 6, 2018 · 14 comments
Open

idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated #163

aaronpk opened this issue Feb 6, 2018 · 14 comments

Comments

@aaronpk
Copy link

aaronpk commented Feb 6, 2018

I'm getting this bizarre error in some cases under PHP 7.2. Apparently the idn_to_ascii function deprecated the INTL_IDNA_VARIANT_2003 variant in PHP 7.2, and you're supposed to use INTL_IDNA_VARIANT_UTS46 instead now. However, PHP seems to be still using INTL_IDNA_VARIANT_2003 as the default if none is specified. This ends up causing an exception.

I think this is wrong behavior of PHP, but it would be easier to fix in this library calling the idn_to_ascii function. I've patched my running instance to call idn_to_ascii($string,0,INTL_IDNA_VARIANT_UTS46) already.

Has anyone else encountered this issue?

@aaronpk
Copy link
Author

aaronpk commented Feb 6, 2018

Did a little digging and it looks like this was already fixed in master! #148 Looking forward to the next release! 🎉

@aaronpk aaronpk closed this as completed Feb 6, 2018
@anupammo
Copy link

think there's a better way to sort out that issue. As we all know that email library not supported in php 7.2 and that's why error occured.

Quick Solution :

  1. Go to cPanel
  2. Select PHP version
  3. change it to 7.1 instead of 7.2

@shafique-uddin
Copy link

think there's a better way to sort out that issue. As we all know that email library not supported in php 7.2 and that's why error occured.

Quick Solution :

  1. Go to cPanel
  2. Select PHP version
  3. change it to 7.1 instead of 7.2

It's an easy way to solve this problem in a second.

@benjaminkohl
Copy link

So what is the real solution to this? I am experiencing this error with version 4.11.0 in PHP 7.2 and I don't consider rolling back to PHP 7.1 to be a reasonable solution. Is PHP to blame for how this function is being called? It looks like symfony/polyfill is defining that constant. Maybe it shouldn't be?

@benjaminkohl
Copy link

To avoid this issue in PHP 7.2, apparently two constants need to be defined but whose responsibility is that and what are the values supposed to be? I'm really surprised the PHP devs decided to deprecate that constant yet leave it as the default value for the third parameter of idn_to_ascii(). This screenshot is from the offending block of code in this library's Host.php file.
Screen Shot 2019-09-17 at 1 41 55 PM

@ezyang
Copy link
Owner

ezyang commented Sep 18, 2019

@benjaminkohl Can you file a new bug for this?

@jaygilmore
Copy link

Was this satisfactorily resolved? I'm seeing errors similar to this in an app where this library is a dependency (Freescout): I'm seeing the following error on PHP 7.2 and above:

idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated (View: www/resources/views/conversations/partials/thread.blade.php) (View: www/resources/views/conversations/partials/thread.blade.php) (View: www/resources/views/conversations/partials/thread.blade.php) {"userId":1,"email":"[email protected]","exception":"[object] (ErrorException(code: 0): idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated (View: www/resources/views/conversations/partials/thread.blade.php) (View: www/resources/views/conversations/partials/thread.blade.php) (View: www/resources/views/conversations/partials/thread.blade.php) at www/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php:103, ErrorException(code: 0): idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated (View: www/resources/views/conversations/partials/thread.blade.php) (View: www/resources/views/conversations/partials/thread.blade.php) at www/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php:103, ErrorException(code: 0): idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated (View: www/resources/views/conversations/partials/thread.blade.php) at www/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php:103, ErrorException(code: 0): idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated at www/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php:103)

I'm not sure if this is a new issue or if I'm supposed to do something to get this to work reliably?

Web Server: nginx/1.16.1
PHP: PHP 7.3.11
OS: centOS6

Any help or guidance would be appreciated.

@ezyang
Copy link
Owner

ezyang commented Jul 1, 2021

did freescout update to a newer version? :)

@jaygilmore
Copy link

The version used is 4.12, so, the PHP7.2+ compatibility should be fine according to your docs. That said, they completely dismissed the issue out of hand stating that the deprecation notice and the simultaneous 500 error that occurs are not related. While I agree that something that throws a deprecation notice isn't the specific culprit of the 500, the 500 still occurs and still stops the application from working when the notice is logged at PHP 7.2+. Thoughts?

@ezyang
Copy link
Owner

ezyang commented Jul 19, 2021

in 4.12 there is not supposed to be any occurrence of INTL_IDNA_VARIANT_2003. Can you grep in Freescout and see where the string INTL_IDNA_VARIANT_2003 occurs?

@freescout-helpdesk
Copy link

freescout-helpdesk commented Jul 26, 2021

@freescout-helpdesk
Copy link

The only way to fix this seems to be:


            try {
                if (defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46')) {
                    $string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
                } else {
                    $string = idn_to_ascii($string);
                }
            } catch (\Exception $e) {
                
            }

@ezyang ezyang reopened this Jul 27, 2021
@freescout-helpdesk
Copy link

Is it ok to create a pull request for this #163 (comment)? PHP developers made a mistake for which there is no other solutions.

@bytestream
Copy link
Contributor

bytestream commented Aug 1, 2021

We need a reproducer and #163 (comment) isn't a valid fix

Did you check phpinfo() for the libicu version on the system that's producing the error?

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

No branches or pull requests

8 participants