[wp-trac] [WordPress Trac] #56198: Check cache key type

WordPress Trac noreply at wordpress.org
Mon Jul 11 18:39:40 UTC 2022


#56198: Check cache key type
-------------------------+-----------------------------
 Reporter:  tillkruess   |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Cache API    |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 It's unfortunately relatively common for plugins to call the
 `wp_cache_*()` methods with an empty-string or `false` as cache key,
 usually as a result of not checking the return value of another function
 that's used as the key.

 Currently this is failing silently and thus leads on odd behavior at best
 and often breakage.

 {{{#!php
 $sessionId = session_id(); // equals "" when session wasn't started
 wp_cache_get( $sessionId );
 }}}

 Doing a quick type check on the given cache keys and calling
 `_doing_it_wrong()` would help plugins developers to notice these issues
 quicker.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56198>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list