By forcing all clause keys to be strings, we make it possible to use strict
comparison when validating values of 'orderby' as passed to `WP_Query`. This
eliminates situations where the presence of numeric clause keys could result
in an improperly validated 'orderby' value.
Props nikolov.tmw.
Fixes#32937.
Built from https://develop.svn.wordpress.org/trunk@34090
git-svn-id: http://core.svn.wordpress.org/trunk@34058 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Setting the default value of the `queried_object_id` property to `0` meant
that, when called early enough in the WP bootstrap, `get_queried_object()`
could short-circuit the normal query by fooling it into thinking that the
request was for a page with id 0. Setting the default value to `null` instead
avoids this problem.
Props gradyetc, jazbek.
Fixes#31355.
Built from https://develop.svn.wordpress.org/trunk@34073
git-svn-id: http://core.svn.wordpress.org/trunk@34041 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* Takes inspiration from `WP_Post` and adds sanity to comment caching.
* Clarifies when the current global value for `$comment` is returned. The current implementation in `get_comment()` introduces side effects and an occasion stale global value for `$comment` when comment caches are cleaned.
* Strongly-types `@param` docs
* This class is marked `final` for now
Props wonderboymusic, nacin.
See #32619.
Built from https://develop.svn.wordpress.org/trunk@33891
git-svn-id: http://core.svn.wordpress.org/trunk@33860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Add a query var, `title`, that allows you to query posts by `post_title`. To accomplish this now, you have to do something like:
{{{
$tacos = get_posts( [
'post_type' => 'taco',
's' => $name,
'exact' => true,
'sentence' => true,
'post_status' => 'publish',
'fields' => 'ids',
'posts_per_page' => 1
] );
}}}
Adds unit tests.
Fixes#33074.
Built from https://develop.svn.wordpress.org/trunk@33706
git-svn-id: http://core.svn.wordpress.org/trunk@33673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`is_array( 1, '1-foo' )` returns true, which means that `is_page( 1 )`
was returning true when on a page with the slug '1-foo'. We avoid this odd
behavior by casting the queried object ID to a string before testing against
the value passed to the conditional function.
This also helps to avoid a problem where an arbitrary value for `$page` would
cause `is_page( $page )` to return true if the query had been manipulated by
a plugin to show that the current page's ID is 0.
Props boonebgorges, r-a-y, nunomorgadinho, wonderboymusic, clifgriffin.
Fixes#24674.
Built from https://develop.svn.wordpress.org/trunk@31458
git-svn-id: http://core.svn.wordpress.org/trunk@31439 1a063a9b-81f0-0310-95a4-ce76da25c4cd
It's possible to have an empty `tax_query` and `is_tax=true` when the initial
query contains a taxonomy var (and is processed as such during
`WP_Query::parse_query()`) but the taxonomy var is unset during a 'parse_query'
callback. While this kind of behavior is not necessarily something we need to
support, we should continue to avoid PHP notices in such cases, as we did prior
to WP 4.1.
Fixes#31246.
Built from https://develop.svn.wordpress.org/trunk@31366
git-svn-id: http://core.svn.wordpress.org/trunk@31347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The implementation of `meta_query` orderby introduced in [31312] put clause
identifiers into a 'name' parameter of the clause. For greater clarity, this
changeset updates the syntax to use the associative array key used when
defining `meta_query` parameters, instead of the 'name' parameter.
Props Funkatronic, DrewAPicture.
Fixes#31045.
Built from https://develop.svn.wordpress.org/trunk@31340
git-svn-id: http://core.svn.wordpress.org/trunk@31321 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`WP_Meta_Query` clauses now support a 'name' parameter. When building a
`WP_Query` object, the value of 'orderby' can reference this 'name', so that
it's possible to order by any clause in a meta_query, not just the first one
(as when using 'orderby=meta_value'). This improvement also makes it possible
to order by multiple meta query clauses (or by any other eligible field plus
a meta query clause), using the array syntax for 'orderby' introduced in [29027].
Props Funkatronic, boonebgorges.
Fixes#31045.
Built from https://develop.svn.wordpress.org/trunk@31312
git-svn-id: http://core.svn.wordpress.org/trunk@31293 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Per our inline documentation standards, no further use of the `@uses` tag is recommended as used and used-by relationships can be derived through other means. This removes most uses of the tag in core documentation, with remaining tags to be converted to `@global` or `@see` as they apply.
Fixes#30191.
Built from https://develop.svn.wordpress.org/trunk@30105
git-svn-id: http://core.svn.wordpress.org/trunk@30105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`setup_postdata()` is responsible for setting a number of global variables
that are used for post pagination (`$pages`, `$page`, `$nextpage`) and the
generation of post excerpts (`$more`). These variables should be sensitive to
the currently running instance of `WP_Query` - rather than the main query -
so that these features work properly inside of secondary `WP_Query` loops.
This changeset moves the logic of `setup_postdata()` into a method on `WP_Query`,
and converts `setup_postdata()` to a wrapper.
Props boonebgorges, wonderboymusic.
See #25349.
Fixes#9256, #20904.
Built from https://develop.svn.wordpress.org/trunk@30085
git-svn-id: http://core.svn.wordpress.org/trunk@30085 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, tax query arguments could be joined by a single AND or OR relation.
Now, these queries can be arbitrarily nested, allowing clauses to be linked
together with multiple relations.
In a few places, WP_Query runs through a list of clauses in a tax_query in order
to set certain query vars for backward compatibility. The necessary changes have
been made to WP_Query to support this feature with the new complex structure of
tax_query. Unit tests are included for these backward compatibility fixes.
Unit tests for the new nesting syntax are included.
Props boonebgorges.
Fixes#29718. See #29738.
Built from https://develop.svn.wordpress.org/trunk@29891
git-svn-id: http://core.svn.wordpress.org/trunk@29647 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When using legacy `meta_key`, `meta_value`, etc. arguments in `WP_Query`,
they're converted into the first clause of a `meta_query`. By using that
clause instead of the original arguments, we make sure that behavior is
consistent between the two available formats.
props boonebgorges.
fixes#16814.
Built from https://develop.svn.wordpress.org/trunk@29855
git-svn-id: http://core.svn.wordpress.org/trunk@29618 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The shortcode callbacks for `gallery` and `playlist` check for `'RAND' == $atts['order']`, which isn't a valid value for `order`. Remove those checks and update the docs.
In `WP_Query`, if the value of `orderby` is `rand`, `order` is irrelevant and should be unset.
Adds unit tests.
Fixes#29629.
Built from https://develop.svn.wordpress.org/trunk@29760
git-svn-id: http://core.svn.wordpress.org/trunk@29532 1a063a9b-81f0-0310-95a4-ce76da25c4cd