fix: compatibility with new version of guzzle (guzzle > 5.3.0 & PHP >= 8)#2670
fix: compatibility with new version of guzzle (guzzle > 5.3.0 & PHP >= 8)#2670emanuelgomez-s1 wants to merge 2 commits intogoogleapis:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
This class is using |
|
Hi @bshaffer, thanks for the feedback! The issue I'm addressing occurs when using "google/apiclient": "^2.9" together with "guzzlehttp/guzzle": "^7.0.1" and PHP 8. In this setup, I'm encountering a critical runtime error because the \GuzzleHttp\Message\ResponseInterface interface no longer exists in Guzzle 6+: Error: Failed opening required '/efs/apps/XXX/model/GuzzleHttp/Message/ResponseInterface.php' (include_path='.:/usr/share/php') This stems from the condition in REST::doExecute(): Even though the class is primarily working with Psr\Http\Message\ResponseInterface, the fallback to \GuzzleHttp\Message\ResponseInterface is what causes the issue on newer setups. Since older versions of Guzzle (e.g., 5.x) are not compatible with PHP 8, referencing interfaces from those versions causes fatal errors in modern environments. My patch updates the condition to a safer and more compatible approach:
This avoids referencing a non-existent interface and maintains compatibility with PSR-7 responses. Let me know if you'd like me to add a test or more context |
|
@emanuelgomez-s1 If anything, I'd say we should remove the whole conditional, as that class no longer exists in any version of guzzle |
|
closing in favor of #2694 |



This PR addresses a compatibility issue in the Google\Http\REST class related to legacy support for GuzzleHttp\Message\ResponseInterface, which was removed in Guzzle 6+. The existing code conditionally checks for this obsolete interface and attempts to convert responses, but this behavior is unnecessary (and potentially problematic) in modern environments using Guzzle >=6 and PHP 8.
The proposed change removes this outdated compatibility layer and ensures cleaner, future-proof code that aligns.
Thanks for your cooperation @macatapichon