[wp-trac] [WordPress Trac] #54428: PHP8.1 deprecation warnings

WordPress Trac noreply at wordpress.org
Fri Nov 12 14:00:49 UTC 2021


#54428: PHP8.1 deprecation warnings
--------------------------+-----------------------------
 Reporter:  michaing      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I recently upgraded to PHP8.1 and see some deprecation warnings now. I
 doesn't cause issues, but you may want to fix this for PHP8.1 release:
 {{{
 PHP message: PHP 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 /var/www/blog/wp-includes/Requests/Cookie/Jar.php on line 63
 PHP message: PHP 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 /var/www/blog/wp-includes/Requests/Cookie/Jar.php on line 73
 PHP message: PHP 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 /var/www/blog/wp-includes/Requests/Cookie/Jar.php on line 89
 PHP message: PHP 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 /var/www/blog/wp-includes/Requests/Cookie/Jar.php on line
 102
 PHP message: PHP 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 /var/www/blog/wp-includes/Requests/Cookie/Jar.php on line
 111
 PHP message: PHP 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 /var/www/blog/wp-
 includes/Requests/Utility/CaseInsensitiveDictionary.php on line 40
 PHP message: PHP 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 /var/www/blog/wp-
 includes/Requests/Utility/CaseInsensitiveDictionary.php on line 51
 PHP message: PHP 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 /var/www/blog/wp-
 includes/Requests/Utility/CaseInsensitiveDictionary.php on line 68
 PHP message: PHP 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 /var/www/blog/wp-
 includes/Requests/Utility/CaseInsensitiveDictionary.php on line 82
 PHP message: PHP Deprecated:  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 in /var/www/blog/wp-
 includes/Requests/Utility/CaseInsensitiveDictionary.php on line 91
 PHP message: PHP Deprecated:  http_build_query(): Passing null to
 parameter #2 ($numeric_prefix) of type string is deprecated in
 /var/www/blog/wp-includes/Requests/Transport/cURL.php on line 345
 }}}
 {{{
 PHP message: PHP Deprecated:  mysqli_real_escape_string(): Passing null to
 parameter #2 ($string) of type string is deprecated in /var/www/blog/wp-
 includes/wp-db.php on line 1168
 }}}
 The second is pretty easy to fix: In `wp-includes/wp-db.php` line 1162
 change the condition from:
 {{{
 if ( ! is_scalar( $string ) && ! is_null( $string ) ) {
 }}}
 to
 {{{

 if ( ! is_scalar( $string ) ) {
 }}}
 Ah, and now I see this has been done already for next release:
 https://github.com/WordPress/WordPress/commit/d345fe2

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54428>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list