[wp-trac] [WordPress Trac] #59594: Remove $taxonomies from cache key generation in WP_Term_Query

WordPress Trac noreply at wordpress.org
Wed Oct 11 22:58:57 UTC 2023


#59594: Remove $taxonomies from cache key generation in WP_Term_Query
-----------------------------------------+-----------------------------
 Reporter:  spacedmonkey                 |       Owner:  (none)
     Type:  enhancement                  |      Status:  new
 Priority:  normal                       |   Milestone:  Future Release
Component:  Taxonomy                     |     Version:
 Severity:  normal                       |  Resolution:
 Keywords:  good-first-bug dev-feedback  |     Focuses:  performance
-----------------------------------------+-----------------------------

Comment (by flixos90):

 This cache key has been used basically forever: It was present in the
 initial version of `WP_Term_Query` (see https://github.com/WordPress
 /wordpress-develop/commit/8b9bdaccd28a95092b14c71df5523ffcd71a321f#diff-
 e11115d9cf3918f9f3436b7be4935810f97d4834a0863b8344b83377b50f1800R614),
 where it was simply taken over from the cache key previously applied in
 `get_terms()` (see https://github.com/WordPress/wordpress-
 develop/commit/8b9bdaccd28a95092b14c71df5523ffcd71a321f#diff-
 7813f38c6b905b75c4b11bf2750c63ba0f5a1227ffc4f012deeeb22999cee68bL1615).

 I think this is worth revisiting. My hunch is that it was simply taken
 over out of caution, as that was a massive change. Even back then, I
 believe the separate `$taxonomies` consideration wasn't necessary in
 `WP_Term_Query` due to [36614], which had already landed before the
 `WP_Term_Query` introduction in [37572].

 `$taxonomies` used to be a separate parameter in `get_terms()`, which is
 the reason this code exists. However for `WP_Term_Query` that was never
 the case, there is only `$args['taxonomy']`. So including that in the
 cache key here is redundant indeed.

 That said, changing that would only be an improvement in terms of cleaning
 up old code. Functionally, it wouldn't make a difference, and there is a
 single potentially negative consideration that making this change would
 make lots of existing caches invalid / outdated. Not necessarily a
 blocker, but worth considering particularly since the benefits of this
 change would IMO be negligible.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59594#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list