There’s a bug in Guzzle 6.5.0 in which it does not play nice with systems that have an older ICU library (which PHP’s Intl extension uses). CentOS 6 for example ships with a very old ICU version, without any (offical) means of updating it. The bug should be fixed in (the unreleased) Guzzle 6.5.1.
It is recommended that all PHP projects avoid Guzzle 6.5.0, by requiring Guzzle as follows:
composer require guzzlehttp/guzzle:'>=6.3.0 <6.5.0 || ^6.5.1'
~
A client of mine reported that he could no longer upload photos to an S3 bucket from within his CraftCMS website. The upload failed with the following message:
Use of undefined constant INTL_IDNA_VARIANT_UTS46 - assumed 'INTL_IDNA_VARIANT_UTS46'
As I had just updated the dependencies of that project, I checked the diff of the composer.json
and saw that Guzzle got bumped to version 6.5.0
~
Although the release notes for 6.5.0 somehow don't mention it, there's a commit in 6.5.0 that reads “Internationalized domain name (IDN) support (#2286)”. In that commit you can find usage of PHP's INTL_IDNA_VARIANT_UTS46
constant.
Checking the list of Intl provided constants, there's this small note next to INTL_IDNA_VARIANT_UTS46
:
Available as of ICU 4.6.
And, as it turns out, the installed version on the CentOS 6 server that serves the project is lower than 4.6:
$ yum list installed icu
…
Installed Packages
icu.x86_64 4.2.1-14.el6
Unfortunately there's no official way of updating ICU to a more recent version on CentOS 6 (*), so a fix needs to happen on Guzzle's end. An issue has been reported with Guzzle and the fix should land in version 6.5.1.
💁♂️ (*) You could try installing this unofficial ICU release from the Remi Repository, but then you'd also need to recompile PHP. This isn't always possible to do – e.g. in cases where it's not your server – and would take us way off.
~
If you – as a PHP developer – are affected by this issue right now, you can work around it by avoiding Guzzle 6.5.0. To do so, require Guzzle as follows:
composer require guzzlehttp/guzzle:'>=6.3.0 <6.5.0 || ^6.5.1'
If you've developed a project which relies on Guzzle, it's recommended to implement this change, just like CraftCMS does, so that your users – who might be running CentOS 6 – are not affected by it.
~
Thank me with a coffee.
I don\'t do this for profit but a small one-time donation would surely put a smile on my face. Thanks!
To stay in the loop you can follow @bramus or follow @bramusblog on Twitter.
Thank you so much!!! Saved me hours of digging..
You’re welcome! Today version 6.5.1 of Guzzle got released, so hopefully not too many folks will get version 6.5.0 anymore.
Thanks for your donation to, it is appreciated 🙂
When I run this command:
composer require guzzlehttp/guzzle:’>=6.3.0 <6.5.0 || ^6.5.1'
I am getting this error:
The system cannot find the file specified.
'6.5.1'' is not recognized as an internal or external command, operable program or batch file.
What should I do, please help me
Works fine here:
You could try replacing the single quotes by double quotes.