WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#27834 closed defect (bug) (fixed)

wp_get_archives invalid query

Reported by: westi Owned by: wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.9
Component: Posts, Post Types Keywords: good-first-bug has-patch needs-testing
Focuses: template Cc:
PR Number:

Description

wp_get_archives( array( 'limit' => 0 ) );

Generates:

SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM wp_posts  WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC 0

We should just ignore a limit of 0 and fallback to the default IMHO

Attachments (2)

27834.diff (1.6 KB) - added by jjeaton 6 years ago.
27834-tests.diff (1.4 KB) - added by jjeaton 6 years ago.
27834 unit tests

Download all attachments as: .zip

Change History (5)

@jjeaton
6 years ago

@jjeaton
6 years ago

27834 unit tests

#1 @jjeaton
6 years ago

  • Keywords has-patch needs-testing added; needs-patch needs-unit-tests removed

Added logic that checks for 0 and sets it to the default. My first unit test for core, so feedback is welcome.

#2 @ocean90
6 years ago

  • Component changed from Appearance to Posts, Post Types
  • Milestone changed from Future Release to 4.0

#3 @wonderboymusic
6 years ago

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

In 28560:

Truly check for ! empty() instead of falsey '' when determining whether to add LIMIT clause to SQL in wp_get_archives().

Props jjeaton for the initial patch.
Fixes #27834.

Note: See TracTickets for help on using tickets.