Opened 15 months ago
Last modified 10 months ago
#63618 new defect (bug)
`is_object_in_term` object cache uses "set" instead of "add"
| Reported by: | nlemoine | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Cache API | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
is_object_in_term should respect [wp_suspend_cache_addition](https://developer.wordpress.org/reference/functions/wp_suspend_cache_addition/) and use wp_cache_add instead of wp_cache_set as in [get_the_terms](https://github.com/WordPress/WordPress/blob/c6041fd40a9d499a5d602be791349068699ef695/wp-includes/category-template.php#L1297-L1303)
Blamed line: https://github.com/WordPress/WordPress/blob/c6041fd40a9d499a5d602be791349068699ef695/wp-includes/taxonomy.php#L4895
I stumbled upon this building a long running WP-CLI command and noticed a memory leak issue while having object cache suspended. Turns out I had a has_category that filled the whole cache with category_relationships keys.
Change History (3)
This ticket was mentioned in PR #9054 on WordPress/wordpress-develop by @nlemoine.
15 months ago
#2
- Keywords has-patch added
Use wp_cache_add instead of wp_cache_set to prevent cache additions when wp_suspend_cache_addition has been set to true.
#3
@
10 months ago
- Keywords has-unit-tests added
- Version trunk
Sorry for the late reply. I'm checking this ticket in preparation for the 6.9 dry run.
Blamed line: https://github.com/WordPress/WordPress/blob/c6041fd40a9d499a5d602be791349068699ef695/wp-includes/taxonomy.php#L4895
At the very least, this issue isn't a new one in an unreleased development version, so we'll remove the version field.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Additional note: term relationships caching is used in multiple functions:
The same code pattern is reused in multiple locations. It may need a central place for handling terms caching.