Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#26064 closed defect (bug) (fixed)

Twenty Fourteen: Correct $query usage in Featured_Content::pre_get_posts()

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: lancewillett's profile lancewillett
Milestone: 3.8 Priority: normal
Severity: normal Version: 3.8
Component: Bundled Theme Keywords:
Focuses: Cc:


Background: [26189] (which should have had a ticket).

Featured_Content::pre_get_posts() has some issues:

  1. No need to set the default $query value to false. The method is hooked to pre_get_posts action and is not called separately, so a WP_Query object is always passed.
  2. The is_a( $query, 'WP_Query' ) check is redundant for the same reason.
  3. $query->is_home() method should be used instead of the is_home() template tag. Before [26189], this was causing a _doing_it_wrong() notice in unit tests. [26189] avoided the notice by moving is_home() to the end of the condition. I guess using $query->is_home() would be the more correct fix.

Attachments (1)

26064.patch (825 bytes) - added by SergeyBiryukov 11 years ago.

Download all attachments as: .zip

Change History (4)

#1 @lancewillett
11 years ago

  • Keywords has-patch commit removed

Thank you for the ticket and updated fix, I was going to ask for a longer explanation anyway. :)

#2 @lancewillett
11 years ago

  • Owner set to lancewillett
  • Resolution set to fixed
  • Status changed from new to closed

In 26255:

Twenty Fourteen: correct $query usage in Featured_Content::pre_get_posts(), props SergeyBiryukov, fixes #26064.

#3 @SergeyBiryukov
11 years ago

In 26257:

Correctly capitalize WP_Query in Featured_Content::pre_get_posts() inline docs. see #26064.

Note: See TracTickets for help on using tickets.