Skip to content

Commit

Permalink
Login and Registration: Fix "passing null to non-nullable" deprecatio…
Browse files Browse the repository at this point in the history
…n 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@51829 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
hellofromtonya committed Sep 20, 2021
1 parent fe9f6a2 commit 506aa74
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/wp-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,10 @@ function wp_login_viewport_meta() {
$errors->add( 'enter_recovery_mode', __( 'Recovery Mode Initialized. Please log in to continue.' ), 'message' );
} elseif ( isset( $_GET['redirect_to'] ) && false !== strpos( $_GET['redirect_to'], 'wp-admin/authorize-application.php' ) ) {
$query_component = wp_parse_url( $_GET['redirect_to'], PHP_URL_QUERY );
parse_str( $query_component, $query );
$query = array();
if ( $query_component ) {
parse_str( $query_component, $query );
}

if ( ! empty( $query['app_name'] ) ) {
/* translators: 1: Website name, 2: Application name. */
Expand Down

0 comments on commit 506aa74

Please sign in to comment.