Commit Graph

557 Commits

Author SHA1 Message Date
Drew Jaynes
ff109ddc5a First-run documention of WP_Query argument defaults.
Props siobhan for some language tweaks. Props DrewAPicture.
See #25367.

Built from https://develop.svn.wordpress.org/trunk@28887


git-svn-id: http://core.svn.wordpress.org/trunk@28686 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-28 23:03:17 +00:00
Sergey Biryukov
aebf8f0fea Make sure the first number in LIMIT clause in WP_Query::get_posts() is always an integer.
fixes #23383.
Built from https://develop.svn.wordpress.org/trunk@28864


git-svn-id: http://core.svn.wordpress.org/trunk@28664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-27 00:04:16 +00:00
Sergey Biryukov
ab06b01eb8 Don't kill an empty search query.
see #11330.
Built from https://develop.svn.wordpress.org/trunk@28804


git-svn-id: http://core.svn.wordpress.org/trunk@28613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-23 13:34:15 +00:00
Sergey Biryukov
d2fc1773ae Prevent multiple hierarchical posts with the same slug from being displayed in single post template.
fixes #28611.
Built from https://develop.svn.wordpress.org/trunk@28803


git-svn-id: http://core.svn.wordpress.org/trunk@28612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-23 13:15:16 +00:00
Scott Taylor
22e5b6932a Revert [28613] and [28664]. A good idea, but too much BC baggage.
See #28099.


Built from https://develop.svn.wordpress.org/trunk@28783


git-svn-id: http://core.svn.wordpress.org/trunk@28596 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-20 16:21:17 +00:00
Scott Taylor
c1e7c2d1de Don't use variable variables in WP_Query::get_posts().
See #27881.

Built from https://develop.svn.wordpress.org/trunk@28737


git-svn-id: http://core.svn.wordpress.org/trunk@28551 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-11 17:50:16 +00:00
Scott Taylor
05eeb16e30 Replace all uses of like_escape() with $wpdb->esc_like().
Props miqrogroove.
See #10041.

Built from https://develop.svn.wordpress.org/trunk@28712


git-svn-id: http://core.svn.wordpress.org/trunk@28528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-10 00:44:15 +00:00
Sergey Biryukov
f598eaa89b Move is_admin check to a more appropriate place.
see #11330.
Built from https://develop.svn.wordpress.org/trunk@28668


git-svn-id: http://core.svn.wordpress.org/trunk@28486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-04 23:47:15 +00:00
Sergey Biryukov
b33c95079b Avoid a PHP notice when using WP_Query::get_queried_object() in pre_get_posts action.
props wpsmith.
fixes #28412.
Built from https://develop.svn.wordpress.org/trunk@28667


git-svn-id: http://core.svn.wordpress.org/trunk@28485 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-04 23:43:15 +00:00
Scott Taylor
1aaa80f48e Prevent admin breakage for s in WP_Query after [28623].
See #11330.


Built from https://develop.svn.wordpress.org/trunk@28666


git-svn-id: http://core.svn.wordpress.org/trunk@28484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-04 20:03:15 +00:00
Scott Taylor
23a53beb7e After [28613], also kill queries that explicityly pass empty arrays to category__in, tag__in, tag_slug__in, and author__in to WP_Query.
Adds unit tests.
Fixes #28099.

Built from https://develop.svn.wordpress.org/trunk@28664


git-svn-id: http://core.svn.wordpress.org/trunk@28482 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-04 17:50:15 +00:00
Scott Taylor
ae3d1fccfb Simplify the logic for determining isset( $this->query['s'] ) after [28612], and don't limit this logic to just the main query.
Props SergeyBiryukov.
Fixes #11330.

Built from https://develop.svn.wordpress.org/trunk@28623


git-svn-id: http://core.svn.wordpress.org/trunk@28444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-29 20:50:15 +00:00
Scott Taylor
d0bdcc3e7a If post_status is passed to WP_Query as an array containing 'any' and anything else, don't exclude the other values if they match when running any's exclusion logic.
Adds unit tests.

Fixes #28007.

Built from https://develop.svn.wordpress.org/trunk@28622


git-svn-id: http://core.svn.wordpress.org/trunk@28443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-29 20:42:18 +00:00
Scott Taylor
c367eb71e5 If post__in or post_parent__in is passed to WP_Query as an empty array, nuke the query. Both vars are currently only checked for truthiness after which they are ignored. Setting these vars at all indicates explicit filtering being desired.
Adds unit test.

Fixes #28099.

Built from https://develop.svn.wordpress.org/trunk@28613


git-svn-id: http://core.svn.wordpress.org/trunk@28437 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-29 06:04:15 +00:00
Scott Taylor
dfb75f0833 When parsing the main query, if s is set to empty: ?s= and $this->is_main_query() && array_key_exists( 's', $this->query ) - kill the query instead of loading the homepage. This will load the search page with no results.
Fixes #11330.


Built from https://develop.svn.wordpress.org/trunk@28612


git-svn-id: http://core.svn.wordpress.org/trunk@28436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-29 05:48:14 +00:00
Scott Taylor
fa38396998 Allow users to sort posts by type in WP_Query.
Props DeBAAT.
Fixes #28214.

Built from https://develop.svn.wordpress.org/trunk@28605


git-svn-id: http://core.svn.wordpress.org/trunk@28429 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-29 00:24:14 +00:00
Scott Taylor
333083debe Apply order to each passed value for orderby in WP_Query:
* Since `orderby` in `WP_Query` can accept space-delimited sets, yet only one `order` value: when multiple values are passed (and `DESC` is the order), the default sort order `ASC` is being applied to all values before the last in the set.
* There is a unit test that sporadically fails since 3.6 in `tests/post/revision` due to multiple posts having the same `post_date` from being added so rapidly
* When ordering revisions in `wp_get_post_revisions()`, order by `post_date ID`
* Change the `order` value in `wp_get_post_revisions()` to `ASC`. This will produce SQL like: `ORDER BY $wpdb->posts.post_date ASC, $wpdb->posts.ID ASC`. Previously, this would have produced SQL like: `ORDER BY $wpdb->posts.post_date DESC`, and with the addition of ` ID`: `ORDER BY $wpdb->posts.post_date ASC, $wpdb->posts.ID DESC`. Clearly, wrong. The original SQL produced: `ORDER BY $wpdb->posts.post_date DESC`. As such, return the reversions in reverse order using `array_reverse()`. Not doing so would break "Preview Changes."
* Add unit tests to assert that all of this works.
* All existing unit tests pass with the change to ordering multiple `orderby`s in `WP_Query`.
* In the future, we should support independent `order` for each `orderby`, see #17065.

Props SergeyBiryukov, wonderboymusic.
Fixes #26042.

Built from https://develop.svn.wordpress.org/trunk@28541


git-svn-id: http://core.svn.wordpress.org/trunk@28367 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-22 18:19:13 +00:00
Scott Taylor
affe27e5d1 WP_Query was only missing one access modifier.
Add access modifier (`public`) to applicable class methods/members of `WP_Rewrite`. I am not brave enough to set some of the `var`s to `private` without more testing.

See #27881, #22234.

Built from https://develop.svn.wordpress.org/trunk@28533


git-svn-id: http://core.svn.wordpress.org/trunk@28359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 17:41:13 +00:00
Scott Taylor
949cfd7a34 Add missing access modifiers to methods in WP_Query. Add magic methods for __get(), __set(), __isset(), __unset(), and __call().
Add unit test for magic methods.

See #27881, #22234.

Built from https://develop.svn.wordpress.org/trunk@28523


git-svn-id: http://core.svn.wordpress.org/trunk@28349 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 06:49:16 +00:00
Scott Taylor
5bc59586da In WP_Query, remove duplicate variable setting:
* In `->parse_search_order()`, a value is always set for `$search_orderby`, no need for empty initialization
* In `->get_posts()`, `$fields` is always set, no need for empty initialization

See #27882.

Built from https://develop.svn.wordpress.org/trunk@28333


git-svn-id: http://core.svn.wordpress.org/trunk@28161 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-06 21:43:20 +00:00
Andrew Nacin
88e3ebe05b Revert the conversion of adjacent post queries to WP_Query. Explanation on the ticket.
Reverts [27285], [27286], [27287], [27288], [27291], [27292], [27293], [27296], [27633], [27634], [27635], and [27692].

see #26937.

Built from https://develop.svn.wordpress.org/trunk@27836


git-svn-id: http://core.svn.wordpress.org/trunk@27670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-29 06:03:15 +00:00
Scott Taylor
a6b9d323c6 When using WP_Query's "fields" => "ids" (or "fields" => "id=>parent"), the returned values should be an array of integers, not array of integers represented by strings.
Adds unit tests. All other unit tests pass.

Props danielbachhuber.
Fixes #27252.


Built from https://develop.svn.wordpress.org/trunk@27686


git-svn-id: http://core.svn.wordpress.org/trunk@27525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-24 18:55:16 +00:00
Andrew Nacin
f75e5a023c WP_Query: allow split_the_query = false to avoid a split.
see #26937.

Built from https://develop.svn.wordpress.org/trunk@27633


git-svn-id: http://core.svn.wordpress.org/trunk@27476 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-20 02:54:15 +00:00
Scott Taylor
db1badfcab In WP_Query::get_queried_object(), account for pre_get_posts by checking for tag when tag_id isn't present. Tags still need to be rolled up into tax_query. Add a unit test confirming expected query vars during and after pre_get_posts.
Props mattonomics for a patch.
See #27362.


Built from https://develop.svn.wordpress.org/trunk@27511


git-svn-id: http://core.svn.wordpress.org/trunk@27354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-12 04:08:18 +00:00
Scott Taylor
c92f58a6d5 On second thought, allow posts_per_rss to be set in pre_get_posts to override the posts_per_rss option. There are backwards compatibility concerns otherwise.
Props nacin.
Partially reverts [27455]. Updates the unit test. See #25380.


Built from https://develop.svn.wordpress.org/trunk@27456


git-svn-id: http://core.svn.wordpress.org/trunk@27302 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-07 18:59:14 +00:00
Scott Taylor
bc968895cc When setting posts_per_page in WP_Query::get_posts(), check for is_feed() in the same place where posts_per_page is set when it is not already set. Previously, when is_feed() was true, posts_per_page would be arbitrarily overwritten. This fix allows posts_per_page to be set during pre_get_posts when is_feed() is true and not be overwritten.
Adds unit test.

Props wokamoto.
Fixes #25380.


Built from https://develop.svn.wordpress.org/trunk@27455


git-svn-id: http://core.svn.wordpress.org/trunk@27301 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-07 18:33:15 +00:00
Andrew Nacin
1ff0aebf20 Add has_password and post_password query variables to WP_Query.
* has_password true means posts with passwords, false means posts without.
 * post_password can query for posts with a particular password.

props wonderboymusic, robmiller.
fixes #20308.

Built from https://develop.svn.wordpress.org/trunk@27395


git-svn-id: http://core.svn.wordpress.org/trunk@27243 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-04 07:45:14 +00:00
Andrew Nacin
1d06679518 Add a $default argument to get_query_var() and WP_Query::get(). fixes #16471.
Built from https://develop.svn.wordpress.org/trunk@27304


git-svn-id: http://core.svn.wordpress.org/trunk@27157 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-26 23:58:14 +00:00
Drew Jaynes
d8a52d7523 Remove now-unnecessary vanity spacing of various hooks in wp-includes/query.php.
See #25514.

Built from https://develop.svn.wordpress.org/trunk@27211


git-svn-id: http://core.svn.wordpress.org/trunk@27068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-20 17:59:13 +00:00
Drew Jaynes
9f9d3f8b8a Inline documentation hooks in wp-includes/query.php.
Covers documentation for the various remaining query hooks, notably including but not limited to:
* `parse_query`
* `parse_tax_query`
* `pre_get_posts`
* `posts_results`
* `the_posts`
* `found_posts`
* `the_post`

Props dougwollison, DrewAPicture.
See #25514.


Built from https://develop.svn.wordpress.org/trunk@27210


git-svn-id: http://core.svn.wordpress.org/trunk@27067 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-20 17:54:13 +00:00
Drew Jaynes
0469b382a3 Inline documentation for various SQL clause hooks in wp-includes/query.php.
Covers documentation for SQL clause hooks related to comment feeds, including:
* `comment_feed_join`
* `comment_feed_where`
* `comment_feed_groupby`
* `comment_feed_orderby`
* `comment_feed_limits`

Props dougwollison, DrewAPicture.
See #25514.


Built from https://develop.svn.wordpress.org/trunk@27208


git-svn-id: http://core.svn.wordpress.org/trunk@27065 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-20 17:46:13 +00:00
Drew Jaynes
6060a66451 Inline documentation for various SQL clause hooks in wp-includes/query.php.
Covers documentation for SQL clause hooks specified for use by caching plugins, including:
* `posts_selection`
* `posts_where_request`
* `posts_groupby_request`
* `posts_join_request`
* `posts_orderby_request`
* `posts_distinct_request`
* `posts_fields_request`
* `post_limits_request`
* `posts_clauses_request`

Props dougwollison, DrewAPicture.
See #25514.


Built from https://develop.svn.wordpress.org/trunk@27207


git-svn-id: http://core.svn.wordpress.org/trunk@27064 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-20 17:41:12 +00:00
Drew Jaynes
742c77fc6f Inline documentation for various SQL clause hooks in wp-includes/query.php.
Covers documentation for general SQL clause hooks, including:
* `posts_where`
* `posts_join`
* `posts_where_paged`
* `posts_groupby`
* `posts_join_paged`
* `posts_orderby`
* `posts_distinct`
* `post_limits`
* `posts_fields`
* `posts_clauses`

Props dougwollison, DrewAPicture.
See #25514.


Built from https://develop.svn.wordpress.org/trunk@27206


git-svn-id: http://core.svn.wordpress.org/trunk@27063 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-20 17:34:14 +00:00
Scott Taylor
d6baca3c35 Fix an error in SQL generation when perm is set and an array is passed for post_status. Adds unit test.
Props oso96_2000.
Fixes #25523.


Built from https://develop.svn.wordpress.org/trunk@27067


git-svn-id: http://core.svn.wordpress.org/trunk@26940 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-02 07:36:13 +00:00
Scott Taylor
d8db2e0cc7 Fix imperceptible whitespace cruff from [27017].
Built from https://develop.svn.wordpress.org/trunk@27018


git-svn-id: http://core.svn.wordpress.org/trunk@26895 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-22 22:35:12 +00:00
Scott Taylor
580d8ab0db Fix a bit of whitespace from [27016].
Built from https://develop.svn.wordpress.org/trunk@27017


git-svn-id: http://core.svn.wordpress.org/trunk@26894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-22 22:34:12 +00:00
Scott Taylor
a9c661c00e Let is_attachment() accept an $attachment parameter, similar to is_page() and is_single(). Adds Unit Tests for all 3.
Props alex-ye for the initial patch.
Fixes #24257.


Built from https://develop.svn.wordpress.org/trunk@27016


git-svn-id: http://core.svn.wordpress.org/trunk@26893 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-22 22:31:12 +00:00
Sergey Biryukov
9572d2d001 Avoid a fatal error in wp_reset_postdata() if $wp_query global is not set.
see #26775 for trunk.
Built from https://develop.svn.wordpress.org/trunk@26932


git-svn-id: http://core.svn.wordpress.org/trunk@26813 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-11 23:57:14 +00:00
Scott Taylor
f3b433cec3 In WP_Query::get_queried_object(), move the check for $query['terms'] to a place where $query is actually set. This should be included if [26864] makes it into 3.8.1.
Props SergeyBiryukov.
See #26728, [26864], #26634, #26627.



Built from https://develop.svn.wordpress.org/trunk@26874


git-svn-id: http://core.svn.wordpress.org/trunk@26758 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-27 19:30:10 +00:00
Scott Taylor
014007f029 Fix a regression for get_queried_object() by checking for category_name when cat isn't set - mainly is_category() being true for Uncategorized or when queried object is accessed in pre_get_posts. Also check for $query['terms'] when trying to assign a term as the queried object when is_tax() is true. Adds a unit test. See [26007] for how I originally broke this while fixing a bigger issue.
Props Chouby, jeremyfelt.
Fixes #26634, #26627.


Built from https://develop.svn.wordpress.org/trunk@26864


git-svn-id: http://core.svn.wordpress.org/trunk@26750 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-22 18:31:12 +00:00
Andrew Nacin
ba55e433a4 Revert [26012] for now, which had fixed using paged with offset in WP_Query but introduced side effects for those working around it.
see #18897.

Built from https://develop.svn.wordpress.org/trunk@26525


git-svn-id: http://core.svn.wordpress.org/trunk@26418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-02 16:26:10 +00:00
Scott Taylor
45deda0726 Fix canonical redirection of cat as described in #15256 by rolling the cat query var into tax_query, instead of category__in / category__not_in. Top-level categories were only redirecting properly if they had no children.
All unit tests pass. Tests marked for #15256 are no longer skipped.

Fixes #15256.
Props dd32.


Built from https://develop.svn.wordpress.org/trunk@26090


git-svn-id: http://core.svn.wordpress.org/trunk@26008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-11 18:36:10 +00:00
Sergey Biryukov
8d659b278c Fix docblock formatting. fixes #25893.
Built from https://develop.svn.wordpress.org/trunk@26081


git-svn-id: http://core.svn.wordpress.org/trunk@26001 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-11 13:32:10 +00:00
Sergey Biryukov
47151b3534 Add @return for WP_Query::parse_search(). props tivnet. fixes #25894.
Built from https://develop.svn.wordpress.org/trunk@26061


git-svn-id: http://core.svn.wordpress.org/trunk@25984 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-09 16:05:10 +00:00
Sergey Biryukov
297e714932 Declare the variable before using it. props tivnet. fixes #25895 for trunk.
Built from https://develop.svn.wordpress.org/trunk@26060


git-svn-id: http://core.svn.wordpress.org/trunk@25983 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-09 15:53:09 +00:00
Scott Taylor
a519007202 Respect paged when offset is used in WP_Query. Adds unit tests.
Props coffee2code.
Fixes #18897.


Built from https://develop.svn.wordpress.org/trunk@26012


git-svn-id: http://core.svn.wordpress.org/trunk@25943 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-05 01:35:10 +00:00
Scott Taylor
ca85591c3c Category and tag are typically checked before checking for a custom taxonomy. If the global query matches category or tag (even if it also has tax_query set), return category/tag as the queried object, instead of arbitrarily returning the first term in the tax_query stack (typically those added with 'pre_get_posts').
Real world example: http://www.emusic.com/17dots/topics/daily-download/ - "tag" page, regionalized for US-only content using `pre_get_posts` passing in the terms "US" and "ALL" for "region" (custom tax). All of the theme functions would output "ALL" as the term name. Even though it was a tag archive, the queried object was an arbitrary term from `tax_query`.

See [26006]. All unit tests pass.
Fixes #20767.



Built from https://develop.svn.wordpress.org/trunk@26007


git-svn-id: http://core.svn.wordpress.org/trunk@25938 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-04 23:54:10 +00:00
Andrew Nacin
3b82280cb4 Query stopwords: Only eliminate single A-Z letters as search terms.
Stop trying to match any single letters that are not East Asian characters, as this requires PCRE with UTF-8 support; and because it doesn't actually work.

fixes #25709.

Built from https://develop.svn.wordpress.org/trunk@25954


git-svn-id: http://core.svn.wordpress.org/trunk@25913 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-27 20:51:10 +00:00
Andrew Nacin
c08aee70bb In search stopwords filtering, suppress possible PHP warnings when PCRE lacks UTF-8 support.
see #25709.

Built from https://develop.svn.wordpress.org/trunk@25932


git-svn-id: http://core.svn.wordpress.org/trunk@25891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-26 05:59:09 +00:00
Andrew Nacin
70fd806759 Revert r25824:25875 from the core.svn.wordpress.org repository.
These commits were accidentally re-synced commits from develop.svn.wordpress.org due to a race condition. Thankfully, the history of this repository matters fairly little. It also happened only for trunk.


git-svn-id: http://core.svn.wordpress.org/trunk@25876 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-25 02:29:52 +00:00