Make WordPress Core

Opened 2 years ago

Closed 23 months ago

Last modified 15 months ago

#55411 closed defect (bug) (duplicate)

Deprecated error in WordPress 5.9 on PHP 8.1

Reported by: meysamnorouzi's profile meysamnorouzi Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: php81 has-patch
Focuses: Cc:

Description

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /opt/lampp/htdocs/wp/wp-includes/block-supports/layout.php on line 167

Deprecated: setcookie(): Passing null to parameter #5 ($domain) of type string is deprecated in /opt/lampp/htdocs/wp/wp-includes/option.php on line 1109

Deprecated: setcookie(): Passing null to parameter #5 ($domain) of type string is deprecated in /opt/lampp/htdocs/wp/wp-includes/option.php on line 1110

Deprecated: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in /opt/lampp/htdocs/wp/wp-includes/formatting.php on line 2761

Change History (10)

#1 @meysamnorouzi
2 years ago

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 /opt/lampp/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 63

Deprecated: 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 in /opt/lampp/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 73

Deprecated: 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 in /opt/lampp/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 89

Deprecated: 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 in /opt/lampp/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 102

Deprecated: 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 in /opt/lampp/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 111

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 /opt/lampp/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 40

Deprecated: 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 in /opt/lampp/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 51

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 /opt/lampp/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 68

Deprecated: 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 in /opt/lampp/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 82

#2 @DarkoG
2 years ago

One more from me

[15-Mar-2022 22:21:33 UTC] PHP Deprecated:  rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/vagrant/code/test/wp-includes/formatting.php on line 2761


Last edited 2 years ago by DarkoG (previous) (diff)

#3 @jrf
2 years ago

  • Keywords php81 reporter-feedback added

Deprecations are not errors. A lot of WordPress functions all suffer from similar issues and we should implement a proper, consistent solution for all, which is why these issues have not been addressed yet as a discussion is needed on the solution direction.

The only time it would be possible to get these deprecation notices, is if these functions are being called with a null being passed to a non-nullable parameter, which is doing it wrong. More than anything, the incorrect function call, should be fixed. Not the function where the deprecation is thrown.

For that a full backtrace of the notices is needed to determine where the incorrect function call is being made.

As for the deprecations from the Requests_* classes, see the dedicated ticket about upgrading the external Requests library: #54504

#4 @SergeyBiryukov
2 years ago

#55624 was marked as a duplicate.

#5 follow-up: @wparslan
2 years ago

@jrf you are right, the functionality doesn't stop.
However, we are left with a lot of unwanted lines on the front-end sometimes breaking the structures.

So have to resolve these deprecation warnings.

#6 in reply to: ↑ 5 @jrf
2 years ago

Replying to wparslan:

@jrf you are right, the functionality doesn't stop.
However, we are left with a lot of unwanted lines on the front-end sometimes breaking the structures.

So have to resolve these deprecation warnings.

@wparslan If you are seeing these on the front-end, turn off WP_DEBUG.

Other than that, resolving these needs a concerted effort and strategy and should not be done hap-snap, as is often done now, resulting in hiding the notices instead of properly fixing them.

There are dedicated tickets for solving these type of PHP cross-version compatibility issues, like #54730.

IMO, this ticket should be closed as a duplicate.

#7 @ocean90
23 months ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 5.9.2 deleted

Marking as a duplicate of #54914, #55119, #54504, and #55656.

This ticket was mentioned in PR #2804 on WordPress/wordpress-develop by ocean90.


23 months ago
#8

  • Keywords has-patch added

Reported in https://core.trac.wordpress.org/ticket/55411 and https://core.trac.wordpress.org/ticket/55656#comment:6.

---

Fixes PHP 8.1 notices on the login screen caused by passing null values to wp_authenticate().

Currently, user_login and user_password are only set to null by a side-effect of this line https://github.com/WordPress/wordpress-develop/blob/793fa4185d6512967e557eed5ac9c419176d2a28/src/wp-includes/user.php#L67
See https://3v4l.org/8JMRM for an example.

I used a simple empty() check which matches the behaviour of functions like `wp_authenticate_username_password()` which are hooked into the authenticate filter.

Trac ticket: https://core.trac.wordpress.org/ticket/55656

#9 @costdev
21 months ago

#56309 was marked as a duplicate.

@SergeyBiryukov commented on PR #2804:


15 months ago
#10

Thanks for the PR! Merged in r55301.

Note: See TracTickets for help on using tickets.