Make WordPress Core

Opened 6 months ago

Last modified 2 weeks ago

#63618 new defect (bug)

`is_object_in_term` object cache uses "set" instead of "add"

Reported by: nlemoine's profile nlemoine Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Cache API Keywords: has-patch has-unit-tests
Focuses: Cc:

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.


6 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 @wildworks
2 weeks ago

  • Keywords has-unit-tests added
  • Version trunk deleted

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.

Note: See TracTickets for help on using tickets.