[wp-trac] [WordPress Trac] #57593: Warn about calling `_get_non_cached_ids()` with invalid ids

WordPress Trac noreply at wordpress.org
Tue Jan 31 18:41:58 UTC 2023


#57593: Warn about calling `_get_non_cached_ids()` with invalid ids
--------------------------+-----------------------------
 Reporter:  tillkruess    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Cache API     |    Version:  trunk
 Severity:  major         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Currently the `_get_non_cached_ids()` function doesn't validate its
 `$object_ids` argument contains only `int[]`. This can lead to call like:


 {{{
 wp_cache_get_multiple( [ null, false, true, 1, 2, 3 ], 'posts' );
 }}}

 or even worse:

 {{{
 wp_cache_get_multiple( [ 1, 2, array() ], 'posts' );
 }}}

 Which is impossible to translate to it's expected return value:

 {{{
 [
     1 => 1,
     2 => 2,
     array() => 0
 ];
 }}}

 Similar to #56198 we should check the given `$object_ids` and at least
 call `_doing_it_wrong()`.

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


More information about the wp-trac mailing list