[wp-trac] [WordPress Trac] #56850: PHP 8.1 deprecation notices from wp_signon() with default parameters

WordPress Trac noreply at wordpress.org
Thu Feb 9 01:29:56 UTC 2023


#56850: PHP 8.1 deprecation notices from wp_signon() with default parameters
-------------------------------------------------+-------------------------
 Reporter:  lenasterg                            |       Owner:
                                                 |  SergeyBiryukov
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  6.2
Component:  Login and Registration               |     Version:
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch php81 has-unit-tests       |     Focuses:
  commit                                         |
-------------------------------------------------+-------------------------
Changes (by SergeyBiryukov):

 * status:  accepted => closed
 * resolution:   => fixed


Comment:

 In [changeset:"55301" 55301]:
 {{{
 #!CommitTicketReference repository="" revision="55301"
 Login and Registration: Set correct default values in `wp_signon()`.

 The `$credentials['user_login']` and `$credentials['user_password']`
 parameters are passed by reference to the `wp_authenticate` action, and
 are at that point
 [https://www.php.net/manual/en/language.references.pass.php#124383 created
 as null] if they don't exist in the array.

 This commit sets those values to an empty string, resolving two PHP 8.1
 deprecation notices:
  * One from `preg_replace()` in `wp_strip_all_tags()` via
 `sanitize_user()` in `wp_authenticate()`:
 {{{
 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of
 type array|string is deprecated
 }}}
  * One from `trim()` in `wp_authenticate()` itself:
 {{{
 Deprecated: trim(): Passing null to parameter #1 ($string) of type string
 is deprecated
 }}}

 Includes documenting the `$credentials` parameter using hash notation.

 Follow-up to [6643], [37697].

 Props lenasterg, TobiasBg, ocean90, afragen, lkraav, SergeyBiryukov.
 Fixes #56850.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56850#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list