WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 3 years ago

#14817 closed defect (bug) (invalid)

update_post_cache() fails when an object is already in the cache

Reported by: misterbisson Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch needs-testing
Focuses: Cc:

Description

The function uses wp_cache_add(), which cannot replace an existing object for the cache key. Should use wp_cache_set(), which happily replaces existing objects or inserts new ones.

Attached patch fixes.

Attachments (1)

update_post_cache_fix.diff (305 bytes) - added by misterbisson 4 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 misterbisson3 years ago

  • Keywords has-patch needs-testing added

comment:2 scribu3 years ago

Related: #15452

comment:3 ryan3 years ago

Despite the name, the update_cache functions aren't meant to update things already in the cache. They are cache primers and typically use add. If some place is using update_post_cache() to update cache values that needs to be fixed.

comment:4 mdawaffe3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Looks like every place in core is using this function correctly (to prime).

Closing as invalid. Please reopen with more details if you find somewhere where the function is being used improperly.

Note: See TracTickets for help on using tickets.