Make WordPress Core


Ignore:
Timestamp:
12/12/2018 03:02:00 AM (8 years ago)
Author:
jeremyfelt
Message:

REST API: Move object type-specific metadata integrations from the wrapper functions to the low-level Meta API functions.

Object type-specific actions that should happen before or after modification of metadata have so far been part of the respective wrapper functions. By using action and filter hooks, this changeset ensures they are always executed, even when calling the lower-level Meta API functions directly, which the REST API does as a prime example.

Merges [43729] to trunk.

Props flixos90, spacedmonkey.
Fixes #44467.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/comment.php

    r43571 r43982  
    443443 */
    444444function add_comment_meta( $comment_id, $meta_key, $meta_value, $unique = false ) {
    445         $added = add_metadata( 'comment', $comment_id, $meta_key, $meta_value, $unique );
    446         if ( $added ) {
    447                 wp_cache_set( 'last_changed', microtime(), 'comment' );
    448         }
    449         return $added;
     445        return add_metadata( 'comment', $comment_id, $meta_key, $meta_value, $unique );
    450446}
    451447
    … …  
    466462 */
    467463function delete_comment_meta( $comment_id, $meta_key, $meta_value = '' ) {
    468         $deleted = delete_metadata( 'comment', $comment_id, $meta_key, $meta_value );
    469         if ( $deleted ) {
    470                 wp_cache_set( 'last_changed', microtime(), 'comment' );
    471         }
    472         return $deleted;
     464        return delete_metadata( 'comment', $comment_id, $meta_key, $meta_value );
    473465}
    474466
    … …  
    507499 */
    508500function update_comment_meta( $comment_id, $meta_key, $meta_value, $prev_value = '' ) {
    509         $updated = update_metadata( 'comment', $comment_id, $meta_key, $meta_value, $prev_value );
    510         if ( $updated ) {
    511                 wp_cache_set( 'last_changed', microtime(), 'comment' );
    512         }
    513         return $updated;
     501        return update_metadata( 'comment', $comment_id, $meta_key, $meta_value, $prev_value );
    514502}
    515503
    … …  
    35133501        );
    35143502}
     3503
     3504/**
     3505 * Sets the last changed time for the 'comment' cache group.
     3506 *
     3507 * @since 5.0.0
     3508 */
     3509function wp_cache_set_comments_last_changed() {
     3510        wp_cache_set( 'last_changed', microtime(), 'comment' );
     3511}
Note: See TracChangeset for help on using the changeset viewer.