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

GuzzleHttp library in Azure CDN provider will conflict with newer guzzlehttp/guzzle composer dependencies in other plugins #642

Closed
figureone opened this issue Jan 31, 2023 · 0 comments · Fixed by #643

Comments

@figureone
Copy link
Contributor

Aloha, W3 Total Cache includes an older GuzzleHttp library (v6.x, I believe) as part of the Microsoft Azure Storage CDN provider:
https://github.com/W3EDGE/w3-total-cache/tree/master/lib/Azure/GuzzleHttp

If W3 Total Cache is configured to use the Azure CDN provider, and if other installed plugins include the guzzlehttp/guzzle composer library v7.x or newer, a fatal error will be triggered when W3 Total Cache tries to load the older GuzzleHttp library. For example:
PHP Fatal error: Cannot redeclare GuzzleHttp\describe_type() (previously declared in /var/www/html/wp-content/plugins/authorizer/vendor/guzzlehttp/guzzle/src/functions.php:16) in /var/www/html/wp-content/plugins/w3-total-cache/lib/Azure/GuzzleHttp/functions.php on line 41
https://github.com/guzzle/guzzle/blob/master/src/functions.php#L5-L19

The root cause is the conditional check for the GuzzleHttp\uri_template function in functions_include.php:
https://github.com/W3EDGE/w3-total-cache/blob/master/lib/Azure/GuzzleHttp/functions_include.php#L4
Guzzle 7.x removed this function, so the conditional passes and tries to load the library, failing once it tries to redeclare the next function, GuzzleHttp\describe_type.

This should be a quick fix in W3 Total Cache (unless you want to move the entire dependency into composer, but I assume that could have side effects). Just check function_exists('GuzzleHttp\describe_type') instead of function_exists('GuzzleHttp\uri_template').
https://github.com/W3EDGE/w3-total-cache/blob/master/lib/Azure/GuzzleHttp/functions_include.php#L4

For reference, the guzzle folks rolled out a similar fix in 7.0.1:
https://github.com/guzzle/guzzle/pull/2699/files

Thanks!

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 a pull request may close this issue.

1 participant