PHP 8.1 compaitbility to http_build_query fix

Created on 8 December 2022, almost 2 years ago
Updated 8 March 2023, over 1 year ago

PHP 8.1 will throw a deprecated error on the http_build_query function call from line 188 of /vendor/vinceg/usps-php-api/src/USPSBase.php

THE FIX

Apply patch from https://www.drupal.org/project/drupal/issues/2248257 - one small omission in the patch at the first file of core/lib/Drupal/Component/Utility/UrlHelper.php at the very bottom there is no " + " sign in front of the " } " but you do need to add that " } " of it will throw a syntax error shown below

+ return http_build_query($query, '', '&', PHP_QUERY_RFC3986);
}

Clear and rebuild cache to make sure the code changes are loaded

Then in USPSBase.php at the top add

use Drupal\Component\Utility\UrlHelper;

and at or around line 188

change => $opts[CURLOPT_POSTFIELDS] = http_build_query($this->getPostData(), null, '&');

to => $opts[CURLOPT_POSTFIELDS] = UrlHelper::buildQuery($this->getPostData(), null, '&');

The quotes should come in again now

🐛 Bug report
Status

Fixed

Version

1.5

Component

Code

Created by

🇺🇸United States bobburns

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States bob.hinrichs

    Thanks, this fix is confusing. Any progress on this problem? Php 7 is no longer supported.

  • 🇺🇸United States bobburns

    To number 3 and 4 - yes it was a pain patching each time a new core came down, but it is now "fixed" almost. I am not the maintainer

    See https://www.drupal.org/project/commerce_usps/issues/3248338 📌 Dependency vinceg/usps-php-api is abandoned Fixed at number 8 - whenever the namespace issue is fixed the issue will be fixed by using the dev version installed with dependencies which will bring down the genyaa usps api

    Note that the genyaa usps api uses curl to call the usps servers so http_build_query is not needed and requires php 8.0

    - PHP >= 8.0
    - Configured with the cURL extension
    - USPS API Username

    I brought down 9.5.4 and it works without the http_build_query patch with the March 3, 2023 version of the dev version

  • Status changed to Fixed over 1 year ago
  • 🇮🇱Israel jsacksick

    So I'm guessing this is fixed with the latest version of the module. Could you try updating and let us know if the issue persists pls?

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024