WordPress.org

Make WordPress Core

Ticket #19708: 19708-2.diff

File 19708-2.diff, 1.2 KB (added by leewillis77, 6 years ago)

Revised patch attached - correctly deals with a false returned from update_postmeta_cache().

  • wp-includes/post.php

     
    15081508/**
    15091509 * Retrieve post meta fields, based on post ID.
    15101510 *
    1511  * The post meta fields are retrieved from the cache, so the function is
    1512  * optimized to be called more than once. It also applies to the functions, that
    1513  * use this function.
     1511 * The post meta fields are retrieved from the cache where possible, so the
     1512 * function is optimized to be called more than once. It also applies to the
     1513 * functions, that use this function.
    15141514 *
    15151515 * @since 1.2.0
    15161516 * @link http://codex.wordpress.org/Function_Reference/get_post_custom
     
    15261526        if ( ! $post_id )
    15271527                $post_id = get_the_ID();
    15281528
    1529         if ( ! wp_cache_get( $post_id, 'post_meta' ) )
    1530                 update_postmeta_cache( $post_id );
     1529        if ( ! wp_cache_get( $post_id, 'post_meta' ) ) {
    15311530
    1532         return wp_cache_get( $post_id, 'post_meta' );
     1531        $post_meta = update_postmeta_cache( $post_id );
     1532
     1533        if ( ! $post_meta )
     1534            return $post_meta;
     1535
     1536        $post_meta = $post_meta [ $post_id ];
     1537
     1538        return $post_meta;
     1539
     1540    } else {
     1541
     1542        return wp_cache_get( $post_id, 'post_meta' );
     1543
     1544    }
     1545
    15331546}
    15341547
    15351548/**