Make WordPress Core

Ticket #38709: query.patch

File query.patch, 682 bytes (added by Khadreal, 8 months ago)

The patch suggested by @rebasaurus remove the query but doesn't resolve the issue as draft post still shows up. Forcing a limit when it's singular and sanitize the input kind of do the trick and resolve it.

  • src/wp-includes/class-wp-query.php

    diff --git forkSrcPrefix/src/wp-includes/class-wp-query.php forkDstPrefix/src/wp-includes/class-wp-query.php
    index f683a52bd108011148b2c76c23dcc78bffc57067..5471d9a9102f5e7de0869090e1e56e0612368449 100644
    old new class WP_Query { 
    21352135                }
    21362136
    21372137                // Parameters related to 'post_name'.
     2138                if( '' === sanitize_title_for_query( $q['name'] ) && true === $this->is_singular ){
     2139                        $this->is_singular = false;
     2140                }
    21382141                if ( '' !== $q['name'] ) {
    21392142                        $q['name'] = sanitize_title_for_query( $q['name'] );
    21402143                        $where    .= " AND {$wpdb->posts}.post_name = '" . $q['name'] . "'";