Make WordPress Core

Changeset 51829


Ignore:
Timestamp:
09/20/2021 06:21:32 PM (3 years ago)
Author:
hellofromTonya
Message:

Login and Registration: Fix "passing null to non-nullable" deprecation for authorize_application error message.

If there is no URL query in the $_GET['redirect_to'], wp_parse_url() will return null. Passing null to parse_str()` results in a PHP 8.1 deprecation notice

Deprecated: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated

This commit:

  • Fixes the deprecation notice.
  • Skips doing the parse_str() when there's no URL query.
  • Provides a micro-optimization performance boost.

Follow-up to [49109].

Props jrf, hellofromTonya, BinaryKitten.
See #53635.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-login.php

    r50677 r51829  
    12681268            } elseif ( isset( $_GET['redirect_to'] ) && false !== strpos( $_GET['redirect_to'], 'wp-admin/authorize-application.php' ) ) {
    12691269                $query_component = wp_parse_url( $_GET['redirect_to'], PHP_URL_QUERY );
    1270                 parse_str( $query_component, $query );
     1270                $query           = array();
     1271                if ( $query_component ) {
     1272                    parse_str( $query_component, $query );
     1273                }
    12711274
    12721275                if ( ! empty( $query['app_name'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.