Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#39022 closed defect (bug) (fixed)

Invalid query parameters in `WP_Customize_Manager`

Reported by: dlh Owned by: westonruter
Priority: normal Milestone: 4.7
Component: Customize Version: 4.7
Severity: normal Keywords: has-patch commit has-unit-tests dev-reviewed
Cc: Focuses:

Description

WP_Customize_Manager passes the number parameter to some WP_Query instances, but, as far as I can tell, WP_Query doesn't accept number.

For instance, in trunk running Twenty Seventeen, after this query: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-customize-manager.php#L1015

The value of $existing_posts_query->request is: "SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_name IN [...] ORDER BY wp_posts.post_date DESC LIMIT 0, 10"

I assume the LIMIT wasn't supposed to be there, so the attached patch would replace number with posts_per_page.

Attachments (2)

39022.diff​ (1.3 KB ) - added by dlh 10 years ago.
39022.1.diff​ (1.9 KB ) - added by westonruter 10 years ago.
Tweak starter content unit test to ensure fix works

Download all attachments as: .zip

Change History (8)

@dlh
10 years ago

#1 @westonruter
10 years ago

  • Milestone Awaiting Review → 4.7
  • Owner set to westonruter
  • Status new → accepted

@westonruter
10 years ago

Tweak starter content unit test to ensure fix works

#2 @westonruter
10 years ago

  • Keywords has-patch commit dev-feedback added

@dlh wow, good catch! You're right.

PSA: get_pages() takes number, get_posts() has the alias numberposts, and WP_Query takes posts_per_page.

This ticket was mentioned in ​Slack in #core by westonruter. ​View the logs.


10 years ago

#4 @pento
10 years ago

  • Keywords has-unit-tests dev-reviewed added; dev-feedback removed

#5 @westonruter
10 years ago

  • Resolution → fixed
  • Status accepted → closed

In 39434:

Customize: Fix posts limit query arg for WP_Query from incorrect number to posts_per_page.

Props dlh.
Fixes #39022.

#6 @westonruter
10 years ago

In 39435:

Customize: Fix posts limit query arg for WP_Query from incorrect number to posts_per_page.

Merges [39434] onto 4.7 branch.
Props dlh.
Fixes #39022 for 4.7.

Note: See TracTickets for help on using tickets.