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

WordPress Trac noreply at wordpress.org
Mon Jul 11 21:53:20 UTC 2022

#56198: Check cache key type
 Reporter:  tillkruess   |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  6.1
Component:  Cache API    |     Version:  trunk
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:

Comment (by malthert):

 >Cache key must not be empty.

 I think this is confusing, because 0 and '0' are valid cache keys but
 technically (in PHP terms) 'empty'.
 I think the single error string that is in the PR now is better.


 Regarding translation:
 Afaik l10n.php might not be loaded yet when this function is called at
 all. Since the object cache is loaded before l10n.php.
 I think a function_exists() check for all translations functions in class-
 wp-object-cache.php is needed.


 `if ( is_string( $key ) && trim( $key ) !== '' ) {`

 I think trimming is a good idea to disallow space only keys.
 However I would do the same for groups then too, to keep things

 `if ( empty( $group ) ) {` => `if ( empty( trim( $group ) ) ) {`

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

More information about the wp-trac mailing list