Make WordPress Core

Opened 22 months ago

Closed 22 months ago

Last modified 22 months ago

#56000 closed enhancement (duplicate)

Validate cache key type in runtime cache to avoid errors when switching to permanent object caches

Reported by: malthert's profile malthert Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.1
Component: Cache API Keywords: has-patch
Focuses: Cc:


wp_cache_set (and therefore WP_Object_Cache->set) accepts int|string keys.

Unfortunately, tons of plugins pass NULL as key to cache due to bad code/error handling on their end.
While this works with the runtime cache, most permanent object caches either a) don't work with NULL keys or b) have unexpected behavior (e.g. they convert null keys to something else, e.g. empty string) before setting the key in the backend (thus causing key collisions)

Since most plugins are developed with permanent object cache off, I think we should validate the key type to at least check it's not null.

Maybe even go a step further, and restrict keys to be int|non-empty-string.

Change History (3)

This ticket was mentioned in PR #2825 on WordPress/wordpress-develop by kkmuffme.

22 months ago

  • Keywords has-patch added

#2 @malthert
22 months ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #56198.

#3 @SergeyBiryukov
22 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.