WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 12 days ago

#47911 reviewing defect (bug)

redirect_guess_404_permalink does not consider public custom posts status

Reported by: goaroundagain Owned by: SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version: 5.2.2
Component: Canonical Keywords: has-patch needs-testing needs-unit-tests
Focuses: Cc:
PR Number:

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 2 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

Download all attachments as: .zip

Change History (9)

#2 @goaroundagain
2 months ago

  • Keywords close added

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

#3 @goaroundagain
2 months 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
2 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

#4 @goaroundagain
2 months ago

  • Keywords has-patch added

#5 @SergeyBiryukov
2 months ago

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

Related: #47574

#6 @davidbaumwald
3 weeks ago

@SergeyBiryukov Is this one still on your radar for 5.3? If not, can me move it to a future milestone?

This ticket was mentioned in Slack in #core by marybaum. View the logs.


12 days ago

#8 @garrett-eclipse
12 days ago

  • Keywords needs-testing needs-unit-tests added
  • Milestone changed from 5.3 to Future Release

Moving this to a Future Release as we're now in beta3 for 5.3 and this change will need testing and possible unit tests.

Note: See TracTickets for help on using tickets.