diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 0defa8227d..9404ed6ea5 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -957,8 +957,9 @@ function redirect_guess_404_permalink() { $where .= $wpdb->prepare( ' AND DAYOFMONTH(post_date) = %d', get_query_var( 'day' ) ); } + $publicly_viewable_statuses = array_filter( get_post_stati(), 'is_post_status_viewable' ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared - $post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'" ); + $post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status IN ('" . implode( "', '", esc_sql( $publicly_viewable_statuses ) ) . "')" ); if ( ! $post_id ) { return false; diff --git a/wp-includes/version.php b/wp-includes/version.php index 66720e0022..eea44f30e2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-53042'; +$wp_version = '6.0-alpha-53043'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.