WordPress.org

Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#47911 reviewing defect (bug)

redirect_guess_404_permalink does not consider public custom posts status

Reported by: goaroundagain Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.2.2
Component: Canonical Keywords: has-patch
Focuses: Cc:

Description

At the moment the redirect_guess_404_permalink function does only consider the default "publish" post status and there is no way around because "publish" ist hard coded:

$post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'" );

From register_post_status: https://codex.wordpress.org/Function_Reference/register_post_status
public: (bool) (optional) Whether posts of this status should be shown in the front end of the site.

For this reason, all post with a custom post status set to public will not be found and return an 404.

I think custom post status with public set to true should also be considered.

Attachments (1)

47911.diff (663 bytes) - added by goaroundagain 4 weeks 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

Download all attachments as: .zip

Change History (6)

#2 @goaroundagain
4 weeks ago

  • Keywords close added

Never mind, just saw that this is fixed with 5.2.2 Great!

#3 @goaroundagain
4 weeks ago

  • Keywords close removed

Sorry for the confusion, its not fixed. Correct link to the linke in 5.2.2: https://core.trac.wordpress.org/browser/tags/5.2.2/src/wp-includes/canonical.php#L686

@goaroundagain
4 weeks 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

#4 @goaroundagain
4 weeks ago

  • Keywords has-patch added

#5 @SergeyBiryukov
4 weeks ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

Related: #47574

Note: See TracTickets for help on using tickets.