Make WordPress Core


Ignore:
Timestamp:
10/17/2022 06:11:58 PM (18 months ago)
Author:
audrasjb
Message:

Grouped backports to the 5.1 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,
  • Widgets: Escape RSS error messages for display.

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

Location:
branches/5.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.1

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

    r47646 r54570  
    426426    public $thumbnails_cached = false;
    427427
     428    /**
     429     * Controls whether an attachment query should include filenames or not.
     430     *
     431     * @since 6.0.3
     432     * @var bool
     433     */
     434    protected $allow_query_attachment_by_filename = false;
    428435    /**
    429436     * Cached list of search stopwords.
     
    13531360            }
    13541361
    1355             $like      = $n . $wpdb->esc_like( $term ) . $n;
    1356             $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 );
     1362            $like = $n . $wpdb->esc_like( $term ) . $n;
     1363
     1364            if ( ! empty( $this->allow_query_attachment_by_filename ) ) {
     1365                $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 );
     1366            } else {
     1367                $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 );
     1368            }
    13571369            $searchand = ' AND ';
    13581370        }
     
    17371749        $q = $this->fill_query_vars( $q );
    17381750
     1751        /**
     1752         * Filters whether an attachment query should include filenames or not.
     1753         *
     1754         * @since 6.0.3
     1755         *
     1756         * @param bool $allow_query_attachment_by_filename Whether or not to include filenames.
     1757         */
     1758        $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false );
     1759        remove_all_filters( 'wp_allow_query_attachment_by_filename' );
     1760
    17391761        // Parse meta query
    17401762        $this->meta_query = new WP_Meta_Query();
     
    21672189        }
    21682190
    2169         if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) ) {
     2191        if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) {
    21702192            $groupby = "{$wpdb->posts}.ID";
    21712193        }
     
    22432265        }
    22442266        $where .= $search . $whichauthor . $whichmimetype;
     2267
     2268        if ( ! empty( $this->allow_query_attachment_by_filename ) ) {
     2269            $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
     2270        }
    22452271
    22462272        if ( ! empty( $this->meta_query->queries ) ) {
Note: See TracChangeset for help on using the changeset viewer.