From 6fd24edbec2f120a9cecf3a67b33c99d81ef429e Mon Sep 17 00:00:00 2001 From: duck_ Date: Tue, 1 May 2012 18:26:38 +0000 Subject: [PATCH] Prevent a notice: don't attempt to parse the query string if it doesn't exist. Props johnjamesjacoby. Fixes #20528. git-svn-id: http://svn.automattic.com/wordpress/trunk@20669 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/canonical.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 490e0a638a..94f8c0f2ff 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -448,10 +448,14 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { */ function _remove_qs_args_if_not_in_url( $query_string, Array $args_to_check, $url ) { $parsed_url = @parse_url( $url ); - parse_str( $parsed_url['query'], $parsed_query ); - foreach ( $args_to_check as $qv ) { - if ( !isset( $parsed_query[$qv] ) ) - $query_string = remove_query_arg( $qv, $query_string ); + if ( ! empty( $parsed_url['query'] ) ) { + parse_str( $parsed_url['query'], $parsed_query ); + foreach ( $args_to_check as $qv ) { + if ( !isset( $parsed_query[$qv] ) ) + $query_string = remove_query_arg( $qv, $query_string ); + } + } else { + $query_string = remove_query_arg( $args_to_check, $query_string ); } return $query_string; }