Make WordPress Core


Ignore:
Timestamp:
02/12/2016 02:46:28 AM (9 years ago)
Author:
boonebgorges
Message:

In delete_metadata(), only invalidate cache for affected objects.

The $delete_all flag in delete_metadata() triggers cache invalidation for
multiple objects. Previously, invalidation took place for all objects matching
the $meta_key parameter, regardless of whether $meta_value was also set.
This resulted in overly aggressive invalidation.

Props rahal.aboulfeth.
Fixes #35797.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/meta.php

    r36509 r36511  
    364364        return false;
    365365
    366     if ( $delete_all )
    367         $object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s", $meta_key ) );
     366    if ( $delete_all ) {
     367        $value_clause = '';
     368        if ( '' !== $meta_value && null !== $meta_value && false !== $meta_value ) {
     369            $value_clause = $wpdb->prepare( " AND meta_value = %s", $meta_value );
     370        }
     371
     372        $object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s $value_clause", $meta_key ) );
     373    }
    368374
    369375    /**
Note: See TracChangeset for help on using the changeset viewer.