Commit Graph

16 Commits

Author SHA1 Message Date
Aaron Jorbin
82911b1756 Cache API: introduce wp_cache_get_last_changed to improve DRY
One thing fairly common to the cache groups is a block of code to look to see when the cache was last changed, and if there isn't one, to set it for the current microtime(). It appears in 8 different places in core. This adds a new helper `wp_cache_get_last_changed` to DRY things up a bit.

Since `wp-includes/cache.php` isn't guaranteed to be loaded, this new function is in `wp-includes/functions.php`

Props spacedmonkey, desrosj.
Fixes #37464.


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


git-svn-id: http://core.svn.wordpress.org/trunk@38792 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-21 02:54:34 +00:00
Boone Gorges
acd764a1d3 Taxonomy: Cache results of term count queries.
Fixes #38295.
Built from https://develop.svn.wordpress.org/trunk@38784


git-svn-id: http://core.svn.wordpress.org/trunk@38727 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-12 15:30:31 +00:00
Gary Pendergast
af69f4ab1a General: Restore usage of $wpdb, instead of $this->db.
Hiding the `$wpdb` global behind a property decreases the readability of the code, as well as causing irrelevant output when dumping an object.

Reverts [38275], [38278], [38279], [38280], [38387].
See #37699.


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


git-svn-id: http://core.svn.wordpress.org/trunk@38711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-10 06:38:31 +00:00
Boone Gorges
3b6314e032 Taxonomy: Use WP_Term_Query when querying for object terms.
The new 'object_ids' parameter for `WP_Term_Query` allows queries for
terms that "belong to" a given object. This change makes it possible
to use `WP_Term_Query` inside of `wp_get_object_terms()`, rather than
assembling a SQL query.

The refactor has a couple of benefits:
* Less redundancy.
* Better consistency in accepted arguments between the term query functions. See #31105.
* Less redundancy.
* Object term queries are now cached. The `get_object_term_cache()` cache remains, and will be a somewhat less fragile secondary cache in front of the query cache (which is subject to frequent invalidation).
* Less redundancy.

A small breaking change: Previously, if a non-hierarchical taxonomy had
terms that had a non-zero 'parent' (perhaps because of a direct SQL
query), `wp_get_object_terms()` would respect the 'parent' argument.
This is in contrast to `WP_Term_Query` and `get_terms()`, which have
always rejected 'parent' queries for non-hierarchical taxonomies. For
consistency, the behavior of `get_terms()` is being applied across the
board: passing 'parent' for a non-hierarchical taxonomy will result in
an empty result set (since the cached taxonomy hierarchy will be empty).

Props flixos90, boonebgorges.
See #37198.
Built from https://develop.svn.wordpress.org/trunk@38667


git-svn-id: http://core.svn.wordpress.org/trunk@38610 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-28 03:55:33 +00:00
Boone Gorges
77a3cc733e Query: 'orderby=include' should support comma-separated lists.
[30052] assumed that 'include' would be an array.

Props TimothyBlynJacobs.
Fixes #37904.
Built from https://develop.svn.wordpress.org/trunk@38500


git-svn-id: http://core.svn.wordpress.org/trunk@38441 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-01 16:51:30 +00:00
Boone Gorges
3d593c5fc1 Eliminate unnecessary variable in WP_Term_Query.
Props ocean90.
Fixes #37544.
Built from https://develop.svn.wordpress.org/trunk@38377


git-svn-id: http://core.svn.wordpress.org/trunk@38318 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-26 18:12:26 +00:00
Scott Taylor
bd816e5182 Taxonomy: in get_terms(), do not assume that legacy args are being passed when the only params are top-level meta_* values. Add keys in WP_Term_Query::__construct().
Adds unit tests.

Props flixos90, boonebgorges.
Fixes #37568.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38278 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-23 14:45:28 +00:00
Scott Taylor
e7ffad7fac Query: add a protected field, $db, (composition, as it were) to WP_*_Query classes to hold the value for the database abstraction, instead of importing the global $wpdb into every method that uses it. Reduces the number of global imports by 32.
See #37699.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38216 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-18 18:21:31 +00:00
Scott Taylor
0598f0bc4b Taxononmy: set WP_Term_Query::terms when returning terms from the cache in WP_Term_Query::get_terms().
See #37591.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38153 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-07 04:48:29 +00:00
Boone Gorges
a2f34d9ee0 In WP_Term_Query, accept a string value for taxonomy.
Props endocreative.
Props ocean90 for review.
Fixes #37545.
Built from https://develop.svn.wordpress.org/trunk@38181


git-svn-id: http://core.svn.wordpress.org/trunk@38122 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-03 13:51:30 +00:00
Boone Gorges
01b9ca2292 Taxonomy: Improve back compat of values passed to 'terms_clauses' filter.
Prior to the introduction of `WP_Term_Query`, the 'orderby' clause
passed to the 'terms_clauses' filter was prefixed by `ORDER BY`. After
`WP_Term_Query`, this was not the case; `ORDER BY` was added after the
filter. As such, plugins filtering 'terms_clauses' and returning an
'orderby' clause beginning with `ORDER BY` resulted in invalid syntax
when `WP_Term_Query` prepended a second `ORDER BY` keyword to
the clause.

This changeset rearranges the way the 'orderby' clause is built so that
it will be passed to 'terms_clauses' in the previous format.

Fixes #37378.
Built from https://develop.svn.wordpress.org/trunk@38099


git-svn-id: http://core.svn.wordpress.org/trunk@38040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-19 02:13:28 +00:00
Dominik Schilling
1036637afc Taxonomy: Remove an unnecessary double assignment in WP_Term_Query::get_terms().
Props birgire.
Fixes #37254.
Built from https://develop.svn.wordpress.org/trunk@38020


git-svn-id: http://core.svn.wordpress.org/trunk@37961 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-09 11:49:29 +00:00
Jeremy Felt
6f3f00ea97 Multisite: Change WP_Network id property to an integer.
For consistency and developer sanity.

Props flixos90.
Fixes #37050.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-26 14:26:29 +00:00
Boone Gorges
defe5e371b Introduce term_taxonomy_id parameter for WP_Term_Query.
Allows the fetching of terms based on `term_taxonomy_id`, or an array of
`term_taxonomy_ids`.

Props spacedmonkey.
Fixes #37074.
Built from https://develop.svn.wordpress.org/trunk@37683


git-svn-id: http://core.svn.wordpress.org/trunk@37649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-11 03:49:27 +00:00
Drew Jaynes
e742a17240 Docs: Link up a reference to the get_terms_args filter in the hook doc for get_terms_defaults.
See #35381. See #36921.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37545 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-26 15:17:27 +00:00
Boone Gorges
df0c758e22 Introduce WP_Term_Query and use in get_terms().
`WP_Term_Query` is modeled on existing query classes, such as those used
for comments and users. It provides a more consistent structure for generating
term queries, and should make it easier to add new functionality in the future.

Props flixos90, boonebgorges.
See #35381.
Built from https://develop.svn.wordpress.org/trunk@37572


git-svn-id: http://core.svn.wordpress.org/trunk@37540 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-26 04:33:30 +00:00