From d495eb4548c34e6ce239a76b1250cf597589893b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 3 Jan 2021 17:56:06 +0000 Subject: [PATCH] Canonical: Check if the post type exists when attempting a canonical redirect. This avoids a PHP notice if the post type is no longer registered. Follow-up to [14595], [35480]. Props bobbingwide, hareesh-pillai. Fixes #40309. Built from https://develop.svn.wordpress.org/trunk@49924 git-svn-id: http://core.svn.wordpress.org/trunk@49623 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/canonical.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 167b5cf562..617bcb352d 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -148,7 +148,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { if ( $redirect_post ) { $post_type_obj = get_post_type_object( $redirect_post->post_type ); - if ( $post_type_obj->public && 'auto-draft' !== $redirect_post->post_status ) { + if ( $post_type_obj && $post_type_obj->public && 'auto-draft' !== $redirect_post->post_status ) { $redirect_url = get_permalink( $redirect_post ); $redirect['query'] = _remove_qs_args_if_not_in_url( diff --git a/wp-includes/version.php b/wp-includes/version.php index 5ac55b9643..dee50eb0d9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-alpha-49923'; +$wp_version = '5.7-alpha-49924'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.