Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#27834 closed defect (bug) (fixed)

wp_get_archives invalid query

Reported by: westi's profile westi Owned by: wonderboymusic's profile 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:


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


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 10 years ago.
27834-tests.diff (1.4 KB) - added by jjeaton 10 years ago.
27834 unit tests

Download all attachments as: .zip

Change History (5)

10 years ago

10 years ago

27834 unit tests

#1 @jjeaton
10 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
10 years ago

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

#3 @wonderboymusic
10 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.