Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#49368 closed defect (bug) (worksforme)

Posts query is broken after changeset 47181

Reported by: audrasjb's profile audrasjb Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.4
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

Looks like one of the recent changes in wp-includes/class-wp-query.php broke some things in WordPress Core trunk.

Running trunk, there is a 404 on every Posts/Page in front end.

The issue is fixed when restoring the previous wp-includes/class-wp-query.php file.

Related changeset: [47181]

Change History (5)

#1 follow-up: @audrasjb
5 years ago

@SergeyBiryukov I made some tests and it looks like it works again if I replace:

// If the post_status was specifically requested, let it pass through.
if ( ! in_array( $status, $q_status ) ) {
        $post_status_obj = get_post_status_object( $status );

        if ( $post_status_obj && ! $post_status_obj->public ) {

with:

$post_status_obj = get_post_status_object( $status );

// If the post_status was specifically requested, let it pass through.
if ( ! $post_status_obj->public && ! in_array( $status, $q_status ) ) {

        if ( $post_status_obj && ! $post_status_obj->public ) {

#2 @audrasjb
5 years ago

Related: #48653

#3 in reply to: ↑ 1 @roytanck
5 years ago

Since get_post_status_object will return null for unregistered post statuses, checking $post_status_obj->public will likely produce warnings.

The purpose of my patch was to check for a valid status object before attempting to get info from it.

#4 in reply to: ↑ description @SergeyBiryukov
5 years ago

Replying to audrasjb:

Running trunk, there is a 404 on every Posts/Page in front end.

Thanks for catching that!

I can reproduce the issue in [47179], which indeed had some broken logic, not allowing any posts with a public status to be viewed. This was also confirmed by unit test failures on Travis.

However, that should be fixed in [47181], which added an if ( ! $post_status_obj ) check to the else part of the initial condition. This seems to work as expected, and the unit tests also pass.

Unfortunately, [47179] made it into the nightly build, while [47181] did not. The nightly build is now refreshed, could you download it and double-check? Thanks again :)

#5 @audrasjb
5 years ago

  • Keywords needs-patch removed
  • Milestone 5.4 deleted
  • Priority changed from high to normal
  • Resolution set to worksforme
  • Severity changed from major to normal
  • Status changed from new to closed

Ah thanks for the detailed informations @SergeyBiryukov !
Indeed, the last nightly build works fine.

Well, closing this ticket as worksforme :-)

Note: See TracTickets for help on using tickets.