Make WordPress Core

Opened 10 months ago

Last modified 10 months ago

#58246 new defect (bug)

'update_meta_cache()' doesn't correctly handle the return value of the 'update_{$meta_type}_metadata_cache' filter

Reported by: donglijun's profile donglijun Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.3
Component: Options, Meta APIs Keywords: has-patch
Focuses: Cc:

Description

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().
wp-includes/meta.php: 1149

        $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.
wp-includes/meta.php: 646

        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;
                }
        }

Attachments (1)

58246.diff (487 bytes) - added by donglijun 10 months ago.

Download all attachments as: .zip

Change History (2)

@donglijun
10 months ago

#1 @donglijun
10 months ago

  • Keywords has-patch added
  • Summary changed from 'update_meta_cache' doesn't correctly handle the return value of the 'update_{$meta_type}_metadata_cache' filter to 'update_meta_cache()' doesn't correctly handle the return value of the 'update_{$meta_type}_metadata_cache' filter
Note: See TracTickets for help on using tickets.