Make WordPress Core

Ticket #40669: 40669-posts.diff

File 40669-posts.diff, 2.3 KB (added by spacedmonkey, 6 years ago)
  • src/wp-includes/post.php

     
    17101710 */
    17111711function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
    17121712        // Make sure meta is added to the post, not a revision.
    1713         if ( $the_post = wp_is_post_revision($post_id) )
     1713        if ( $the_post = wp_is_post_revision( $post_id ) ) {
    17141714                $post_id = $the_post;
     1715        }
    17151716
    1716         return add_metadata('post', $post_id, $meta_key, $meta_value, $unique);
    1717 }
     1717        $added = add_metadata( 'post', $post_id, $meta_key, $meta_value, $unique );
     1718
     1719        if ( $added ) {
     1720                wp_cache_set( 'last_changed', microtime(), 'posts' );
     1721        }
    17181722
     1723        return $added;
     1724}
    17191725/**
    17201726 * Remove metadata matching criteria from a post.
    17211727 *
     
    17331739 */
    17341740function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) {
    17351741        // Make sure meta is added to the post, not a revision.
    1736         if ( $the_post = wp_is_post_revision($post_id) )
     1742        if ( $the_post = wp_is_post_revision( $post_id ) ) {
    17371743                $post_id = $the_post;
     1744        }
     1745
     1746        $deleted = delete_metadata( 'post', $post_id, $meta_key, $meta_value );
     1747
     1748        if ( $deleted ) {
     1749                wp_cache_set( 'last_changed', microtime(), 'posts' );
     1750        }
    17381751
    1739         return delete_metadata('post', $post_id, $meta_key, $meta_value);
     1752        return $deleted;
    17401753}
    17411754
    17421755/**
     
    17751788 */
    17761789function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
    17771790        // Make sure meta is added to the post, not a revision.
    1778         if ( $the_post = wp_is_post_revision($post_id) )
     1791        if ( $the_post = wp_is_post_revision( $post_id ) ) {
    17791792                $post_id = $the_post;
     1793        }
    17801794
    1781         return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
     1795        $updated = update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value );
     1796
     1797        if ( $updated ) {
     1798                wp_cache_set( 'last_changed', microtime(), 'posts' );
     1799        }
     1800
     1801        return $updated;
    17821802}
    17831803
    17841804/**
     
    17901810 * @return bool Whether the post meta key was deleted from the database.
    17911811 */
    17921812function delete_post_meta_by_key( $post_meta_key ) {
    1793         return delete_metadata( 'post', null, $post_meta_key, '', true );
     1813        $deleted = delete_metadata( 'post', null, $post_meta_key, '', true );
     1814
     1815        if ( $deleted ) {
     1816                wp_cache_set( 'last_changed', microtime(), 'posts' );
     1817        }
     1818
     1819        return $deleted;
    17941820}
    17951821
    17961822/**