Skip to content

Commit 506aa74

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@51829 602fd350-edb4-49c9-b593-d223f7449a82
1 parent fe9f6a2 commit 506aa74

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/wp-login.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,10 @@ function wp_login_viewport_meta() {
12671267
$errors->add( 'enter_recovery_mode', __( 'Recovery Mode Initialized. Please log in to continue.' ), 'message' );
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'] ) ) {
12731276
/* translators: 1: Website name, 2: Application name. */

0 commit comments

Comments
 (0)