WordPress.org

Make WordPress Core

Ticket #36711: 36711.2.patch

File 36711.2.patch, 965 bytes (added by spacedmonkey, 6 years ago)
  • src/wp-includes/post.php

     
    42484248
    42494249        $post_types = esc_sql( $post_types );
    42504250        $post_type_in_string = "'" . implode( "','", $post_types ) . "'";
     4251
     4252        $key          = $in_string . ":" . $post_type_in_string;
     4253        $last_changed = wp_cache_get( 'last_changed', 'posts' );
     4254        if ( ! $last_changed ) {
     4255                $last_changed = microtime();
     4256                wp_cache_set( 'last_changed', $last_changed, 'posts' );
     4257        }
     4258        $cache_key = "get_page_by_path:$key:$last_changed";
     4259        if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
     4260           return get_post( $cache, $output );
     4261        }
     4262
    42514263        $sql = "
    42524264                SELECT ID, post_name, post_parent, post_type
    42534265                FROM $wpdb->posts
     
    42844296                        }
    42854297                }
    42864298        }
     4299   
     4300        wp_cache_set( $cache_key, $foundid, 'posts' );
    42874301
    42884302        if ( $foundid ) {
    42894303                return get_post( $foundid, $output );