Canonical: Check if the author parameter is a string in redirect_canonical().

This avoids a PHP warning or error when viewing an author on the front end, while an array is passed as `$_GET['author']`.

Follow-up to [12034], [12040], [12202].

Props david.binda, antonvlasenko, azaozz, SergeyBiryukov.
Fixes #60059.
Built from https://develop.svn.wordpress.org/trunk@57232


git-svn-id: http://core.svn.wordpress.org/trunk@56738 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-12-29 13:54:17 +00:00
parent 4388ba3a03
commit 366d370d37
2 changed files with 4 additions and 2 deletions

View File

@ -316,7 +316,9 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
$redirect['query'] = remove_query_arg( 'year', $redirect['query'] );
}
}
} elseif ( is_author() && ! empty( $_GET['author'] ) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) {
} elseif ( is_author() && ! empty( $_GET['author'] )
&& is_string( $_GET['author'] ) && preg_match( '|^[0-9]+$|', $_GET['author'] )
) {
$author = get_userdata( get_query_var( 'author' ) );
if ( false !== $author

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.5-alpha-57231';
$wp_version = '6.5-alpha-57232';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.