The logic used to generate clause SQL in `WP_Meta_Query` is somewhat arcane,
stemming mostly from an ongoing effort to eliminate costly table joins when
they are not necessary. By systematizing the process of looking for shareable
joins - as was done in `WP_Tax_Query` [29902] - it becomes possible to simplify
the construction of SQL queries in `get_sql_for_clause()`. Moreover, the
simplified logic is actually considerably better at identifying shareable
joins, such that certain uses of `WP_Meta_Query` will see joins reduced by 50%
or more.
Includes integration tests for a representative cross-section of the query
clause combinations that result in shared table aliases.
Props boonebgorges, sc0ttkclark.
See #24093.
Built from https://develop.svn.wordpress.org/trunk@29940
git-svn-id: http://core.svn.wordpress.org/trunk@29691 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The 'inclusive' parameter for WP_Date_Query determines whether non-precise
dates for 'before' and 'after' will be rounded up or down. Previously, this was
supported only when 'before' and 'after' were arrays; string-formatted dates
were run through strtotime(), which rounded them all down (inclusive in the
case of after, non-inclusive in the case of before). Now, we attempt to parse
formats that look like MySQL-formatted date strings, and apply inclusive logic
to them if we recognize them successfully.
Fixes#29908.
string values. Array values support the 'inclusive
Built from https://develop.svn.wordpress.org/trunk@29936
git-svn-id: http://core.svn.wordpress.org/trunk@29688 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The use of non-aliased column names (eg 'post_date' instead of 'wp_posts.post_date')
in WP_Date_Query causes SQL notices and other failures when queries involve
table joins, such as date_query combined with tax_query or meta_query. This
changeset modifies WP_Date_Query::validate_column() to add the table alias when
it can be detected from the column name (ie, in the case of core columns).
A side effect of this change is that it is now possible to use WP_Date_Query
to build WHERE clauses across multiple tables, though there is currently no
core support for the automatic generation of the necessary JOIN clauses. See
Props ew_holmes, wonderboymusic, neoxx, Viper007Bond, boonebgorges.
Fixes#25775.
Built from https://develop.svn.wordpress.org/trunk@29933
git-svn-id: http://core.svn.wordpress.org/trunk@29685 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Since [29925], passing an invalid date to WP_Date_Query will generate a
_doing_it_wrong() notice. The current changeset adds the
`@expectedIncorrectUsage` flag to those existing unit tests that generate
invalid dates, such as those that test canonical redirect and is_404()
conditionals.
Fixes#25834.
Built from https://develop.svn.wordpress.org/trunk@29932
git-svn-id: http://core.svn.wordpress.org/trunk@29684 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This enhancement makes it possible to filter post, comment, and other queries
by date in ways that are arbitrarily complex, using mixed AND and OR relations.
Includes unit tests for the new syntax. In a few places, the existing unit
tests were slightly too strict (such as when checking the exact syntax of a SQL
string); these existing tests have been narrowed.
Props boonebgorges.
Fixes#29822.
Built from https://develop.svn.wordpress.org/trunk@29923
git-svn-id: http://core.svn.wordpress.org/trunk@29675 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* Add a helper function, `wp_get_last_changed()`, to retrieve a last-modified timestamp by cache group
* When caching a term, also make cache entries for slug and name via `slug:{$term_id}` and `name:{$term_id}` keys in the `$taxonomy:$last_changed` bucket that reference the term_id
* In `clean_term_cache()` and `update_term_cache()`, respect `$_wp_suspend_cache_invalidation`
* Original term cache entries maintain BC
Adds unit tests.
Props wonderboymusic, tollmanz, boonebgorges.
Fixes#21760.
Built from https://develop.svn.wordpress.org/trunk@29915
git-svn-id: http://core.svn.wordpress.org/trunk@29668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
IN clauses that are connected by OR require only a single table join. To avoid
extraneous joins, keep track of generated table aliases, and let sibling
clauses piggy-back on those aliases when possible.
Introduces WP_Tax_Query::sanitize_relation() to reduce some repeated code.
Adds unit tests to verify the JOIN consolidation, and integration tests for
cases where JOINS are being combined.
Props boonebgorges, otto42, jakub.tyrcha.
Fixes#18105.
Built from https://develop.svn.wordpress.org/trunk@29902
git-svn-id: http://core.svn.wordpress.org/trunk@29657 1a063a9b-81f0-0310-95a4-ce76da25c4cd
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 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