[wp-trac] [WordPress Trac] #21760: get_term_by() calls are not cached
WordPress Trac
noreply at wordpress.org
Wed Sep 28 12:12:26 UTC 2016
#21760: get_term_by() calls are not cached
-------------------------------------------------+-------------------------
Reporter: wonderboymusic | Owner:
Type: enhancement | wonderboymusic
Priority: normal | Status: reopened
Component: Taxonomy | Milestone: Future
Severity: normal | Release
Keywords: 2nd-opinion has-patch needs-unit- | Version: 2.3
tests | Resolution:
| Focuses:
| performance
-------------------------------------------------+-------------------------
Comment (by ocean90):
@pento and I are looking into #meta1829. We noticed that o2 does several
uncached term queries. Some of them could be reduced by
[https://github.com/Automattic/o2/commit/ded62692d2e60de4b9699f28036f64cd78688b55
caching term calls statically]. The others are caused by `get_term_by()`.
The latest patch [attachment:21760.4.patch] by @spacedmonkey looks sane to
me. It makes `get_term_by()` a wrapper for `get_term()` which uses
`WP_Term_Query` and its query cache. @boonebgorges suggested this idea in
comment:87 and I think it's worth a try. I applied the patch on my dotorg
sandbox and the number of queries went down by ~50%.
Looking at the current test coverage, `Tests_Term_GetTermBy` has a few
tests but I think we should extend them, especially with tests for slashed
data and something for `sanitize_title()`.
@boonebgorges What do you think? Happy to own this for 4.7.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21760#comment:94>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list