Make WordPress Core


Ignore:
Timestamp:
10/17/2022 06:08:00 PM (4 years ago)
Author:
audrasjb
Message:

Grouped backports to the 5.2 branch.

  • Editor: Bump @wordpress packages for the branch,
  • Media: Refactor search by filename within the admin,
  • REST API: Lockdown post parameter of the terms endpoint,
  • Customize: Escape blogname option in underscores templates,
  • Query: Validate relation in WP_Date_Query,
  • Posts, Post types: Apply KSES to post-by-email content,
  • General: Validate host on "Are you sure?" screen,
  • Posts, Post types: Remove emails from post-by-email logs,
  • Pings/trackbacks: Apply KSES to all trackbacks,
  • Mail: Reset PHPMailer properties between use,
  • Comments: Apply kses when editing comments,
  • Widgets: Escape RSS error messages for display.

Merges [54521-54530] to the 5.2 branch.
Props audrasjb, costdev, cu121, dd32, davidbaumwald, ehtis, johnbillion, johnjamesjacoby, martinkrcho, matveb, oztaser, paulkevan, peterwilsoncc, ravipatel, SergeyBiryukov, talldanwp, timothyblynjacobs, tykoted, voldemortensen, vortfu, xknown.

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

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

    r47645 r54563  
    434434        public $thumbnails_cached = false;
    435435
     436        /**
     437         * Controls whether an attachment query should include filenames or not.
     438         *
     439         * @since 6.0.3
     440         * @var bool
     441         */
     442        protected $allow_query_attachment_by_filename = false;
    436443        /**
    437444         * Cached list of search stopwords.
    … …  
    13701377                        }
    13711378
    1372                         $like      = $n . $wpdb->esc_like( $term ) . $n;
    1373                         $search   .= $wpdb->prepare( "{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s))", $like, $like, $like );
     1379                        $like = $n . $wpdb->esc_like( $term ) . $n;
     1380
     1381                        if ( ! empty( $this->allow_query_attachment_by_filename ) ) {
     1382                                $search .= $wpdb->prepare( "{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s) $andor_op (sq1.meta_value $like_op %s))", $like, $like, $like, $like );
     1383                        } else {
     1384                                $search .= $wpdb->prepare( "{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s))", $like, $like, $like );
     1385                        }
    13741386                        $searchand = ' AND ';
    13751387                }
    … …  
    17541766                $q = $this->fill_query_vars( $q );
    17551767
     1768                /**
     1769                 * Filters whether an attachment query should include filenames or not.
     1770                 *
     1771                 * @since 6.0.3
     1772                 *
     1773                 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames.
     1774                 */
     1775                $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false );
     1776                remove_all_filters( 'wp_allow_query_attachment_by_filename' );
     1777
    17561778                // Parse meta query
    17571779                $this->meta_query = new WP_Meta_Query();
    … …  
    21842206                }
    21852207
    2186                 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) ) {
     2208                if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) {
    21872209                        $groupby = "{$wpdb->posts}.ID";
    21882210                }
    … …  
    22602282                }
    22612283                $where .= $search . $whichauthor . $whichmimetype;
     2284
     2285                if ( ! empty( $this->allow_query_attachment_by_filename ) ) {
     2286                        $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
     2287                }
    22622288
    22632289                if ( ! empty( $this->meta_query->queries ) ) {
Note: See TracChangeset for help on using the changeset viewer.