#43142 closed enhancement (fixed)
Do not warm term meta cache unnecessarily
Reported by: | peterwilsoncc | Owned by: | peterwilsoncc |
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | performance | Cc: |
Description (last modified by )
A number of core functions calls to get_terms()
warm the term meta cache unnecessarily. Most notably, _get_term_hierarchy()
warms the term meta cache for all of a taxonomy's terms.
Attachments (4)
Change History (14)
#2
@
7 years ago
I noticed a few places in the wp_(insert|update)_term()
workflow where the meta cache may be getting warmed unnecessarily, I'll do a further review and make this ticket generic if needs be.
#3
@
7 years ago
- Description modified (diff)
- Summary changed from Do not warm term meta cache in `_get_term_hierarchy` to Do not warm term meta cache unnecessarily
#4
@
7 years ago
- Keywords commit removed
Commit keyword removed as it applies to the previous patch.
43142.2.diff removes term caching from several instances in src/wp-includes/taxonomy.php
:
wp_insert_term()
: search for siblings with the same namewp_insert_term()
: search for all siblingswp_set_object_terms()
: search for oldtt_ids
usingwp_get_object_terms()
wp_set_object_terms()
: search for finaltt_ids
usingwp_get_object_terms()
_get_term_hierarchy()
: hierarchy update as in previous patch
@boonebgorges would you mind taking another look at the new patch? It's the calls setting an objects terms that I am least sure about.
#5
@
7 years ago
Thanks for taking a closer look, @peterwilsoncc. The functional changes look good to me.
43142.3.diff includes two coding standards changes:
- No spaces in
$args['parent']
- You broke each argument for
wp_get_object_terms()
into its own line. This is not a strict violation of the coding standards, but I haven't seen this specific function use this formatting before. I changed it to what I see as the more common format. But maybe this could use advice from @jrf. (See right-hand 2460 in 43142.3.diff and 43142.2.diff )
#6
@
7 years ago
You broke each argument for wp_get_object_terms() into its own line. This is not a strict violation of the coding standards, but I haven't seen this specific function use this formatting before. I changed it to what I see as the more common format. But maybe this could use advice from @jrf. (See right-hand 2460 in 43142.3.diff and 43142.2.diff )
@boonebgorges Thanks for the ping. I've just had a quick look and the function layout in 43142.2.diff is correct.
The rules which come into play here are:
- For multi-item associative arrays, each array item should start on their own line.
- For multi-line function calls, each parameter should start on their own line.
These rules have been correctly applied in the patch 2. In the patch 3, the second rule is disregarded.
Hope this helps ;-)
#7
@
7 years ago
@jrf Thanks for chiming in. Could you point me toward where the following rule is codified, either in WPCS or in the documentation? (Mainly so I don't have to bug you in the future.) I ran what I thought was the most recent WordPress-Core standards against both 2 and 3 and didn't see a notice either way, but it's likely I was doing something wrong.
For multi-line function calls, each parameter should start on their own line.
#8
@
7 years ago
- Owner set to peterwilsoncc
- Status changed from new to assigned
In 43142.4.diff, coding standards!
It's 43142.2.diff with spacing fixed for $args['parent']
following the feedback above. Ta.
+1