PHP 8.1 DomDocument ceateElements throwing error

Created on 9 December 2022, almost 2 years ago
Updated 13 March 2024, 8 months ago

It appears " $this->getDescription())); " has to be changed to " $this->getDescription()?: "")); " on the listed lines below to escape passing the NULL

Upgrade to PHP 8.1 and Commerce UPS will stop working throwing erros as:

`Deprecated: DOMDocument::createElement(): Passing null to parameter #2 ($value) of type string is deprecated in /var/www/vendor/gabrielbull/ups-api/src/Entity/PickupType.php on line 46

Deprecated: DOMDocument::createElement(): Passing null to parameter #2 ($value) of type string is deprecated in /var/www/vendor/gabrielbull/ups-api/src/Entity/Service.php on line 160

Deprecated: DOMDocument::createElement(): Passing null to parameter #2 ($value) of type string is deprecated in /var/www/vendor/gabrielbull/ups-api/src/Entity/ShipTo.php on line 145

Deprecated: DOMDocument::createElement(): Passing null to parameter #2 ($value) of type string is deprecated in /var/www/vendor/gabrielbull/ups-api/src/Entity/ShipTo.php on line 146

Deprecated: DOMDocument::createElement(): Passing null to parameter #2 ($value) of type string is deprecated in /var/www/vendor/gabrielbull/ups-api/src/Entity/PackagingType.php on line 96

Deprecated: DOMDocument::createElement(): Passing null to parameter #2 ($value) of type string is deprecated in /var/www/vendor/gabrielbull/ups-api/src/Entity/UnitOfMeasurement.php on line 105

Deprecated: DOMDocument::createElement(): Passing null to parameter #2 ($value) of type string is deprecated in /var/www/vendor/gabrielbull/ups-api/src/Entity/UnitOfMeasurement.php on line 105`

So, the issue appears to originate in: /vendor/gabrielbull/ups-api. All ups-api I have found have the same code calling DOMDocument::createElement():

That said, it worked on PHP 7.4 and does not on PHP 8.1

A potential fix is

$this->getDescription()?: ""));

instead of

$this->getDescription()));

at each line affected - I did not do this to the others - because I do not like to fix thngs that do not appear to be broke

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇺🇸United States bobburns

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024