[wp-trac] [WordPress Trac] #29894: get_terms() isn't caching - duplicate queries generated
WordPress Trac
noreply at wordpress.org
Thu Oct 9 01:41:29 UTC 2014
#29894: get_terms() isn't caching - duplicate queries generated
------------------------------------------+-----------------------------
Reporter: webgeekconsulting | Owner: boonebgorges
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: Future Release
Component: Taxonomy | Version: 4.0
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses: performance
------------------------------------------+-----------------------------
Changes (by boonebgorges):
* keywords: has-patch => needs-patch needs-unit-tests
* milestone: 4.1 => Future Release
Comment:
webgeekconsulting - Thanks - I'm not sure that update3.diff is the entire
patch you meant to attach, but I can see enough to understand what you're
suggesting.
After further thought, it appears that using merely the SQL to generate a
cache key is not going to work. `get_terms()` returns different kinds of
values depending on the value of the 'fields' parameter, but these
different values come from the same database query. Using the SQL alone to
create a cache key isn't fine-grained enough.
I think we have to go with a more conservative approach here. Let's keep
using the `$args` array to generate the cache key, but let's typecast all
of the cache keys as necessary. Eg:
{{{
$args['hide_empty'] = (bool) $args['hide_empty'];
}}}
and so on, with all of the relevant arguments. However, I don't think we
can safely make these kinds of changes without more complete unit tests,
because there are places in the function where loose typing is expected -
see eg https://core.trac.wordpress.org/browser/tags/4.0/src/wp-
includes/taxonomy.php#L1290.
I'm attaching a simple unit test that demonstrates the problem as
originally reported.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29894#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list