Make WordPress Core

Opened 16 months ago

Closed 7 months ago

Last modified 4 weeks ago

#56935 closed defect (bug) (worksforme)

Various deprecated warnings with WP 6.0.3 and PHP 8.1

Reported by: applemango's profile applemango Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.0.3
Component: Upgrade/Install Keywords: php81
Focuses: Cc:

Description (last modified by SergeyBiryukov)

I recently tried updating a WP 6.0.3 install to use PHP 8.1 but I immediately get various deprecated warnings from core code.

For example here's a selection:

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/applhpqm/public_html/wp-includes/formatting.php on line 5385

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/applhpqm/public_html/wp-includes/pluggable.php on line 599

Deprecated: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/applhpqm/public_html/wp-includes/formatting.php on line 2772

Deprecated: 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 in /home/applhpqm/public_html/wp-includes/Requests/Cookie/Jar.php on line 63

Deprecated: 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 in /home/applhpqm/public_html/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 40

Deprecated: 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 in /home/applhpqm/public_html/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 68

Deprecated: http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated in /home/applhpqm/public_html/wp-includes/Requests/Transport/cURL.php on line 345

Downgrading to 8.0 suppresses the errors.

Change History (10)

#1 @SergeyBiryukov
16 months ago

  • Description modified (diff)
  • Keywords php81 added

This ticket was mentioned in Slack in #core-test by ironprogrammer. View the logs.


16 months ago

#3 follow-up: @titsmaker
14 months ago

Hi, maybe my posting won't add anything to the discussion, I would gladly add it as a comment somewhere in https://make.wordpress.org/ but the topic has not been discussed since the very beginning of 2022.
So I would ask WP devs to prioritize these deprecations as many people use

define('WP_DEBUG', true)

even on live sites because testing everything on local machine is often impossible, also that way some edge cases can be revealed. Currently PHP 8.0 is in the very end of it's lifecycle (only security support till November of 2023) and we still can't switch to PHP 8.1 as it populate our log with hundreds of such deprecations (mainly in functions.php, formatting.php and different parts of requests library).

Last edited 14 months ago by titsmaker (previous) (diff)

#4 in reply to: ↑ 3 @SergeyBiryukov
14 months ago

Replying to titsmaker:

So I would ask WP devs to prioritize these deprecations

It is worth noting that many of these notices are already resolved in current trunk (6.2-alpha) as part of the work on #54504, #54914, #55656, #55967, #56620, #56681, #56712, and other tickets. I no longer see them on a clean install of 6.2-alpha with PHP 8.2.

This ticket was mentioned in Slack in #core-php by dingo_d. View the logs.


13 months ago

#6 @Soean
7 months ago

@applemango This issue should be fixed in WordPress 6.2, can you confirm it?

#7 @applemango
7 months ago

@Soean Hey man, I can confirm that the warnings no longer appear! This is awesome and means I can now upgrade my servers to PHP8+. Phew, thank you!

#8 @Soean
7 months ago

  • Keywords close added
  • Resolution set to worksforme
  • Status changed from new to closed

#9 @Soean
7 months ago

  • Keywords close removed

#10 @swissspidy
4 weeks ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.