WordPress.org

Make WordPress Core

Ticket #36711: 36711.patch

File 36711.patch, 1.0 KB (added by spacedmonkey, 6 years ago)
  • wp-includes/post.php

    diff --git a/wp-includes/post.php b/wp-includes/post.php
    index 98aeef5..8f9d55d 100644
    a b function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) { 
    42454245
    42464246        $post_types = esc_sql( $post_types );
    42474247        $post_type_in_string = "'" . implode( "','", $post_types ) . "'";
     4248
     4249        $key          = $parts . ":" . $post_type_in_string;
     4250        $last_changed = wp_cache_get( 'last_changed', 'posts' );
     4251        if ( ! $last_changed ) {
     4252                $last_changed = microtime();
     4253                wp_cache_set( 'last_changed', $last_changed, 'posts' );
     4254        }
     4255        $cache_key = "get_page_by_path:$key:$last_changed";
     4256        if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
     4257                return get_post( $cache, $output );
     4258        }
     4259
    42484260        $sql = "
    42494261                SELECT ID, post_name, post_parent, post_type
    42504262                FROM $wpdb->posts
    function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) { 
    42814293                        }
    42824294                }
    42834295        }
    4284 
     4296        wp_cache_set( $cache_key, $foundid, 'posts' );
    42854297        if ( $foundid ) {
    42864298                return get_post( $foundid, $output );
    42874299        }