[PHP Obsolete code] PHP 8.1 compatibility
-
WooCommerce uses some obsolete code for PHP 8.1
Upon visitting any backoffice page, we can see the following errors with the help of Query Monitor plugin:
Obsolète class_exists(): Passing null to parameter #1 ($class) of type string is deprecated 6 wp-content/plugins/woocommerce/includes/wc-core-functions.php:2050 Extension : woocommerce Obsolète Return type of ActionScheduler_DateTime::setTimezone($timezone) should either be compatible with DateTime::setTimezone(DateTimeZone $timezone): DateTime, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_DateTime.php:60 Extension : woocommerce Obsolète Return type of ActionScheduler_DateTime::getOffset() should either be compatible with DateTime::getOffset(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_DateTime.php:48 Extension : woocommerce Obsolète Return type of ActionScheduler_DateTime::getTimestamp() should either be compatible with DateTime::getTimestamp(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_DateTime.php:27 Extension : woocommerce Obsolète Return type of Requests_Utility_CaseInsensitiveDictionary::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-includes/Requests/Utility/CaseInsensitiveDictionary.php:40 Extension : woocommerce Obsolète Return type of Requests_Utility_CaseInsensitiveDictionary::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-includes/Requests/Utility/CaseInsensitiveDictionary.php:51 Extension : woocommerce Obsolète Return type of Requests_Utility_CaseInsensitiveDictionary::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-includes/Requests/Utility/CaseInsensitiveDictionary.php:68 Extension : woocommerce Obsolète Return type of Requests_Utility_CaseInsensitiveDictionary::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-includes/Requests/Utility/CaseInsensitiveDictionary.php:82 Extension : woocommerce Obsolète Return type of Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-includes/Requests/Utility/CaseInsensitiveDictionary.php:91 Extension : woocommerce Obsolète Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-includes/Requests/Cookie/Jar.php:63 Extension : woocommerce Obsolète Return type of Requests_Cookie_Jar::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-includes/Requests/Cookie/Jar.php:73 Extension : woocommerce Obsolète Return type of Requests_Cookie_Jar::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-includes/Requests/Cookie/Jar.php:89 Extension : woocommerce Obsolète Return type of Requests_Cookie_Jar::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-includes/Requests/Cookie/Jar.php:102 Extension : woocommerce Obsolète Return type of Requests_Cookie_Jar::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice 1 wp-includes/Requests/Cookie/Jar.php:111 Extension : woocommerce Obsolète explode(): Passing null to parameter #2 ($string) of type string is deprecated 1 wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php:371 Extension : woocommerce Obsolète parse_str(): Passing null to parameter #1 ($string) of type string is deprecated 1 wp-content/plugins/woocommerce/src/Admin/PageController.php:128 Extension : woocommerce
These are only warnings, however some refactor appears to be required in order to ensure proper PHP 8.1 compatibility and especially to prepare for PHP 8.2 which would probably transform these warnings into errors.
Best regards
The page I need help with: [log in to see the link]
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘[PHP Obsolete code] PHP 8.1 compatibility’ is closed to new replies.