Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years 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:

Description

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.


3 years ago
#1

  • Keywords has-patch added

#2 @malthert
3 years ago

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

Duplicate of #56198.

#3 @SergeyBiryukov
3 years ago

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