This information applies only to

Magento 2.4.4 in conjunction with PHP 8.1


Problem

When trying to create or print shipping labels, this error may occur:


Deprecated Functionality: Optional parameter $genNum declared before required parameter $factory is implicitly treated as a required parameter in /var/www/html/vendor/magento/zendframework1/library/Zend/Pdf/Element/Reference.php on line 91


Cause

See this issue on Github.


This problem is not caused by the DHL extension, but by the Magento Zend Framework. It only occurs when using Magento 2.4.4 together with PHP 8.1. Older versions are not affected.


Solution

A clean solution must be provided by the developers of Magento and/or the Zend Framework. It cannot be resolved by the DHL extension.


As a temporary workaround you can add the following Error Reporting setting to the file "pub/index.php" :

+ error_reporting(E_ALL & ~E_DEPRECATED);
+
$bootstrap = Bootstrap::create(BP, $_SERVER);