Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#28401 closed defect (bug) (fixed)

Redundant condition in WP_Query::get_posts()

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.0 Priority: low
Severity: minor Version: 2.2
Component: Query Keywords: has-patch
Focuses: Cc:

Description

This condition in WP_Query::get_posts() appears to be redundant:

if ( $this->is_comment_feed && ( $this->is_archive || $this->is_search || !$this->is_singular ) )

Unless I'm missing something, it could be simplified to:

if ( $this->is_comment_feed && ! $this->is_singular )

Introduced in [4934]. The change doesn't affect any of the current unit tests.

Attachments (2)

get-posts-redundant-condition.28401.diff (612 bytes) - added by engelen 11 years ago.
get-posts-redundant-condition.28401-2.diff (610 bytes) - added by engelen 11 years ago.
Syntax fix

Download all attachments as: .zip

Change History (5)

#1 @wonderboymusic
11 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.0

#2 @engelen
11 years ago

  • Keywords has-patch added; needs-patch removed

(get-posts-redundant-condition.28401.diff: forgot to commit syntax change before diffing, get-posts-redundant-condition.28401-2.diff is the right diff)

I agree, this is a redundant check. is_archive and is_search can only be true if is_singular is false. Checking for ! is_singular is enough.

#3 @SergeyBiryukov
11 years ago

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

In 29257:

Remove a redundant condition for comment feeds from WP_Query::get_posts().

props engelen.
fixes #28401.

Note: See TracTickets for help on using tickets.