WordPress.org

Make WordPress Core

Ticket #47911: 47911.diff

File 47911.diff, 663 bytes (added by goaroundagain, 3 months ago)

Easy fix, just query all public post stati and change the query to IN linke already done with post types in https://core.trac.wordpress.org/browser/tags/5.2.2/src/wp-includes/canonical.php#L673

  • src/wp-includes/canonical.php

    diff --git a/src/wp-includes/canonical.php b/src/wp-includes/canonical.php
    index 557e36acd9..2a3f9c27e1 100644
    a b function redirect_guess_404_permalink() { 
    704704                        $where .= $wpdb->prepare( ' AND DAYOFMONTH(post_date) = %d', get_query_var( 'day' ) );
    705705                }
    706706
    707                 $post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'" );
     707                $post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status IN ('" . implode( "', '", get_post_stati( array( 'public' => true ) ) ) . "')" );
    708708                if ( ! $post_id ) {
    709709                        return false;
    710710                }