#56000 closed enhancement (duplicate)
Validate cache key type in runtime cache to avoid errors when switching to permanent object caches
Reported by: |
|
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)
Note: See
TracTickets for help on using
tickets.
Fixes: https://core.trac.wordpress.org/ticket/56000