[wp-trac] [WordPress Trac] #58246: 'update_meta_cache' doesn't correctly handle the return value of the 'update_{$meta_type}_metadata_cache' filter

WordPress Trac noreply at wordpress.org
Wed May 3 17:24:26 UTC 2023


#58246: 'update_meta_cache' doesn't correctly handle the return value of the
'update_{$meta_type}_metadata_cache' filter
--------------------------------+-----------------------------
 Reporter:  donglijun           |      Owner:  (none)
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Options, Meta APIs  |    Version:  trunk
 Severity:  normal              |   Keywords:
  Focuses:                      |
--------------------------------+-----------------------------
 The return type of `update_meta_cache()` is `array` or `false`, but the
 return value of `update_{$meta_type}_metadata_cache` filter is forcibly
 cast to `bool` and returned in `update_meta_cache()`.
 [https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/meta.php#L1149 wp-includes/meta.php: 1149]
 {{{#!php
         $check = apply_filters( "update_{$meta_type}_metadata_cache",
 null, $object_ids );
         if ( null !== $check ) {
                 return (bool) $check;
         }
 }}}

 This may cause `get_metadata_raw()` to produce incorrect results.
 [https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/meta.php#L646 wp-includes/meta.php: 646]
 {{{#!php
         if ( ! $meta_cache ) {
                 $meta_cache = update_meta_cache( $meta_type, array(
 $object_id ) );
                 if ( isset( $meta_cache[ $object_id ] ) ) {
                         $meta_cache = $meta_cache[ $object_id ];
                 } else {
                         $meta_cache = null;
                 }
         }
 }}}

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


More information about the wp-trac mailing list