Make WordPress Core

Changeset 54559


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

Grouped backports to the 5.4 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.4 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.4
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • branches/5.4

  • branches/5.4/src/wp-admin/includes/ajax-actions.php

    r47245 r54559  
    29512951        // Filter query clauses to include filenames.
    29522952        if ( isset( $query['s'] ) ) {
    2953                 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     2953                add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
    29542954        }
    29552955
  • branches/5.4/src/wp-admin/includes/post.php

    r47410 r54559  
    12541254        // Filter query clauses to include filenames.
    12551255        if ( isset( $q['s'] ) ) {
    1256                 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     1256                add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
    12571257        }
    12581258
  • branches/5.4/src/wp-includes/class-wp-date-query.php

    r47122 r54559  
    150150                }
    151151
    152                 if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) {
    153                         $this->relation = 'OR';
     152                if ( isset( $date_query['relation'] ) ) {
     153                        $this->relation = $this->sanitize_relation( $date_query['relation'] );
    154154                } else {
    155155                        $this->relation = 'AND';
     
    221221                        $this->validate_date_values( $queries );
    222222                }
     223
     224                // Sanitize the relation parameter.
     225                $queries['relation'] = $this->sanitize_relation( $queries['relation'] );
    223226
    224227                foreach ( $queries as $key => $q ) {
     
    10401043                return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time );
    10411044        }
     1045
     1046        /**
     1047         * Sanitizes a 'relation' operator.
     1048         *
     1049         * @since 6.0.3
     1050         *
     1051         * @param string $relation Raw relation key from the query argument.
     1052         * @return string Sanitized relation ('AND' or 'OR').
     1053         */
     1054        public function sanitize_relation( $relation ) {
     1055                if ( 'OR' === strtoupper( $relation ) ) {
     1056                        return 'OR';
     1057                } else {
     1058                        return 'AND';
     1059                }
     1060        }
    10421061}
  • branches/5.4/src/wp-includes/class-wp-query.php

    r47641 r54559  
    442442        public $thumbnails_cached = false;
    443443
     444        /**
     445         * Controls whether an attachment query should include filenames or not.
     446         *
     447         * @since 6.0.3
     448         * @var bool
     449         */
     450        protected $allow_query_attachment_by_filename = false;
    444451        /**
    445452         * Cached list of search stopwords.
     
    13891396                        }
    13901397
    1391                         $like      = $n . $wpdb->esc_like( $term ) . $n;
    1392                         $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 );
     1398                        $like = $n . $wpdb->esc_like( $term ) . $n;
     1399
     1400                        if ( ! empty( $this->allow_query_attachment_by_filename ) ) {
     1401                                $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 );
     1402                        } else {
     1403                                $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 );
     1404                        }
    13931405                        $searchand = ' AND ';
    13941406                }
     
    17741786                $q = $this->fill_query_vars( $q );
    17751787
     1788                /**
     1789                 * Filters whether an attachment query should include filenames or not.
     1790                 *
     1791                 * @since 6.0.3
     1792                 *
     1793                 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames.
     1794                 */
     1795                $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false );
     1796                remove_all_filters( 'wp_allow_query_attachment_by_filename' );
     1797
    17761798                // Parse meta query.
    17771799                $this->meta_query = new WP_Meta_Query();
     
    22052227                }
    22062228
    2207                 if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) ) {
     2229                if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) {
    22082230                        $groupby = "{$wpdb->posts}.ID";
    22092231                }
     
    22812303                }
    22822304                $where .= $search . $whichauthor . $whichmimetype;
     2305
     2306                if ( ! empty( $this->allow_query_attachment_by_filename ) ) {
     2307                        $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
     2308                }
    22832309
    22842310                if ( ! empty( $this->meta_query->queries ) ) {
  • branches/5.4/src/wp-includes/comment.php

    r47888 r54559  
    23382338        }
    23392339
     2340        $filter_comment = false;
     2341        if ( ! has_filter( 'pre_comment_content', 'wp_filter_kses' ) ) {
     2342                $filter_comment = ! user_can( isset( $comment['user_id'] ) ? $comment['user_id'] : 0, 'unfiltered_html' );
     2343        }
     2344
     2345        if ( $filter_comment ) {
     2346                add_filter( 'pre_comment_content', 'wp_filter_kses' );
     2347        }
     2348
    23402349        // Escape data pulled from DB.
    23412350        $comment = wp_slash( $comment );
     
    23472356
    23482357        $commentarr = wp_filter_comment( $commentarr );
     2358
     2359        if ( $filter_comment ) {
     2360                remove_filter( 'pre_comment_content', 'wp_filter_kses' );
     2361        }
    23492362
    23502363        // Now extract the merged array.
  • branches/5.4/src/wp-includes/customize/class-wp-customize-header-image-control.php

    r45932 r54559  
    131131
    132132                        <button type="button" class="choice thumbnail"
    133                                 data-customize-image-value="{{{data.header.url}}}"
     133                                data-customize-image-value="{{data.header.url}}"
    134134                                data-customize-header-image-data="{{JSON.stringify(data.header)}}">
    135135                                <span class="screen-reader-text"><?php _e( 'Set image' ); ?></span>
    136                                 <img src="{{{data.header.thumbnail_url}}}" alt="{{{data.header.alt_text || data.header.description}}}">
     136                                <img src="{{data.header.thumbnail_url}}" alt="{{data.header.alt_text || data.header.description}}" />
    137137                        </button>
    138138
  • branches/5.4/src/wp-includes/customize/class-wp-customize-site-icon-control.php

    r47382 r54559  
    6969                                                                <img src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/>
    7070                                                        </div>
    71                                                         <span class="browser-title" aria-hidden="true"><# print( '<?php bloginfo( 'name' ); ?>' ) #></span>
     71                                                        <span class="browser-title" aria-hidden="true"><# print( '<?php echo esc_js( get_bloginfo( 'name' ) ); ?>' ) #></span>
    7272                                                </div>
    7373                                                <img class="app-icon-preview" src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" alt="<?php esc_attr_e( 'Preview as an app icon' ); ?>"/>
  • branches/5.4/src/wp-includes/deprecated.php

    r47567 r54559  
    39663966        return wp_get_user_request( $request_id );
    39673967}
     3968
     3969
     3970/**
     3971 * Filter the SQL clauses of an attachment query to include filenames.
     3972 *
     3973 * @since 4.7.0
     3974 * @deprecated 6.0.3
     3975 * @access private
     3976 *
     3977 * @param array $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY,
     3978 *                       DISTINCT, fields (SELECT), and LIMITS clauses.
     3979 * @return array The unmodified clauses.
     3980 */
     3981function _filter_query_attachment_filenames( $clauses ) {
     3982        _deprecated_function( __FUNCTION__, '6.0.3', 'add_filter( "wp_allow_query_attachment_by_filename", "__return_true" )');
     3983        remove_filter( 'posts_clauses', __FUNCTION__ );
     3984        return $clauses;
     3985}
  • branches/5.4/src/wp-includes/functions.php

    r51745 r54559  
    32223222                $html = __( 'The link you followed has expired.' );
    32233223                if ( wp_get_referer() ) {
    3224                         $html .= '</p><p>';
    3225                         $html .= sprintf(
     3224                        $wp_http_referer = remove_query_arg( 'updated', wp_get_referer() );
     3225                        $wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) );
     3226                        $html           .= '</p><p>';
     3227                        $html           .= sprintf(
    32263228                                '<a href="%s">%s</a>',
    3227                                 esc_url( remove_query_arg( 'updated', wp_get_referer() ) ),
     3229                                esc_url( $wp_http_referer ),
    32283230                                __( 'Please try again.' )
    32293231                        );
  • branches/5.4/src/wp-includes/media-template.php

    r47202 r54559  
    14471447                                <img id="preview-favicon" src="{{ data.url }}" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/>
    14481448                        </div>
    1449                         <span class="browser-title" aria-hidden="true"><# print( '<?php bloginfo( 'name' ); ?>' ) #></span>
     1449                        <span class="browser-title" aria-hidden="true"><# print( '<?php echo esc_js( get_bloginfo( 'name' ) ); ?>' ) #></span>
    14501450                </div>
    14511451
  • branches/5.4/src/wp-includes/pluggable.php

    r47955 r54559  
    312312                $phpmailer->clearCustomHeaders();
    313313                $phpmailer->clearReplyTos();
     314                $phpmailer->Body    = '';
     315                $phpmailer->AltBody = '';
    314316
    315317                // Set "From" name and email.
  • branches/5.4/src/wp-includes/post.php

    r52469 r54559  
    19731973 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
    19741974 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
     1975 * @since 5.9.0 Added `is_post_type_viewable` hook to filter the result.
    19751976 *
    19761977 * @param string|WP_Post_Type $post_type Post type name or object.
     
    19801981        if ( is_scalar( $post_type ) ) {
    19811982                $post_type = get_post_type_object( $post_type );
     1983
    19821984                if ( ! $post_type ) {
    19831985                        return false;
     
    19851987        }
    19861988
    1987         return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
     1989        if ( ! is_object( $post_type ) ) {
     1990                return false;
     1991        }
     1992
     1993        $is_viewable = $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
     1994
     1995        /**
     1996         * Filters whether a post type is considered "viewable".
     1997         *
     1998         * The returned filtered value must be a boolean type to ensure
     1999         * `is_post_type_viewable()` only returns a boolean. This strictness
     2000         * is by design to maintain backwards-compatibility and guard against
     2001         * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     2002         * and truthy values) will result in the function returning false.
     2003         *
     2004         * @since 5.9.0
     2005         *
     2006         * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     2007         * @param WP_Post_Type $post_type   Post type object.
     2008         */
     2009        return true === apply_filters( 'is_post_type_viewable', $is_viewable, $post_type );
     2010}
     2011
     2012/**
     2013 * Determines whether a post status is considered "viewable".
     2014 *
     2015 * For built-in post statuses such as publish and private, the 'public' value will be evaluated.
     2016 * For all others, the 'publicly_queryable' value will be used.
     2017 *
     2018 * @since 5.7.0
     2019 * @since 5.9.0 Added `is_post_status_viewable` hook to filter the result.
     2020 *
     2021 * @param string|stdClass $post_status Post status name or object.
     2022 * @return bool Whether the post status should be considered viewable.
     2023 */
     2024function is_post_status_viewable( $post_status ) {
     2025        if ( is_scalar( $post_status ) ) {
     2026                $post_status = get_post_status_object( $post_status );
     2027
     2028                if ( ! $post_status ) {
     2029                        return false;
     2030                }
     2031        }
     2032
     2033        if (
     2034                ! is_object( $post_status ) ||
     2035                $post_status->internal ||
     2036                $post_status->protected
     2037        ) {
     2038                return false;
     2039        }
     2040
     2041        $is_viewable = $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public );
     2042
     2043        /**
     2044         * Filters whether a post status is considered "viewable".
     2045         *
     2046         * The returned filtered value must be a boolean type to ensure
     2047         * `is_post_status_viewable()` only returns a boolean. This strictness
     2048         * is by design to maintain backwards-compatibility and guard against
     2049         * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     2050         * and truthy values) will result in the function returning false.
     2051         *
     2052         * @since 5.9.0
     2053         *
     2054         * @param bool     $is_viewable Whether the post status is "viewable" (strict type).
     2055         * @param stdClass $post_status Post status object.
     2056         */
     2057        return true === apply_filters( 'is_post_status_viewable', $is_viewable, $post_status );
     2058}
     2059
     2060/**
     2061 * Determines whether a post is publicly viewable.
     2062 *
     2063 * Posts are considered publicly viewable if both the post status and post type
     2064 * are viewable.
     2065 *
     2066 * @since 5.7.0
     2067 *
     2068 * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
     2069 * @return bool Whether the post is publicly viewable.
     2070 */
     2071function is_post_publicly_viewable( $post = null ) {
     2072        $post = get_post( $post );
     2073
     2074        if ( ! $post ) {
     2075                return false;
     2076        }
     2077
     2078        $post_type   = get_post_type( $post );
     2079        $post_status = get_post_status( $post );
     2080
     2081        return is_post_type_viewable( $post_type ) && is_post_status_viewable( $post_status );
    19882082}
    19892083
     
    71387232
    71397233/**
    7140  * Filter the SQL clauses of an attachment query to include filenames.
    7141  *
    7142  * @since 4.7.0
    7143  * @access private
    7144  *
    7145  * @global wpdb $wpdb WordPress database abstraction object.
    7146  *
    7147  * @param string[] $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY,
    7148  *                          DISTINCT, fields (SELECT), and LIMITS clauses.
    7149  * @return string[] The modified array of clauses.
    7150  */
    7151 function _filter_query_attachment_filenames( $clauses ) {
    7152         global $wpdb;
    7153         remove_filter( 'posts_clauses', __FUNCTION__ );
    7154 
    7155         // Add a LEFT JOIN of the postmeta table so we don't trample existing JOINs.
    7156         $clauses['join'] .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
    7157 
    7158         $clauses['groupby'] = "{$wpdb->posts}.ID";
    7159 
    7160         $clauses['where'] = preg_replace(
    7161                 "/\({$wpdb->posts}.post_content (NOT LIKE|LIKE) (\'[^']+\')\)/",
    7162                 '$0 OR ( sq1.meta_value $1 $2 )',
    7163                 $clauses['where']
    7164         );
    7165 
    7166         return $clauses;
    7167 }
    7168 
    7169 /**
    71707234 * Sets the last changed time for the 'posts' cache group.
    71717235 *
  • branches/5.4/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    r47391 r54559  
    8080                // Filter query clauses to include filenames.
    8181                if ( isset( $query_args['s'] ) ) {
    82                         add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     82                        add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
    8383                }
    8484
  • branches/5.4/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    r47166 r54559  
    136136
    137137        /**
     138         * Checks if the terms for a post can be read.
     139         *
     140         * @since 6.0.3
     141         *
     142         * @param WP_Post         $post    Post object.
     143         * @param WP_REST_Request $request Full details about the request.
     144         * @return bool Whether the terms for the post can be read.
     145         */
     146        public function check_read_terms_permission_for_post( $post, $request ) {
     147                // If the requested post isn't associated with this taxonomy, deny access.
     148                if ( ! is_object_in_taxonomy( $post->post_type, $this->taxonomy ) ) {
     149                        return false;
     150                }
     151
     152                // Grant access if the post is publicly viewable.
     153                if ( is_post_publicly_viewable( $post ) ) {
     154                        return true;
     155                }
     156
     157                // Otherwise grant access if the post is readable by the logged in user.
     158                if ( current_user_can( 'read_post', $post->ID ) ) {
     159                        return true;
     160                }
     161
     162                // Otherwise, deny access.
     163                return false;
     164        }
     165
     166        /**
    138167         * Checks if a request has access to read terms in the specified taxonomy.
    139168         *
     
    156185                                array( 'status' => rest_authorization_required_code() )
    157186                        );
     187                }
     188
     189                if ( ! empty( $request['post'] ) ) {
     190                        $post = get_post( $request['post'] );
     191
     192                        if ( ! $post ) {
     193                                return new WP_Error(
     194                                        'rest_post_invalid_id',
     195                                        __( 'Invalid post ID.' ),
     196                                        array(
     197                                                'status' => 400,
     198                                        )
     199                                );
     200                        }
     201
     202                        if ( ! $this->check_read_terms_permission_for_post( $post, $request ) ) {
     203                                return new WP_Error(
     204                                        'rest_forbidden_context',
     205                                        __( 'Sorry, you are not allowed to view terms for this post.' ),
     206                                        array(
     207                                                'status' => rest_authorization_required_code(),
     208                                        )
     209                                );
     210                        }
    158211                }
    159212
  • branches/5.4/src/wp-includes/widgets.php

    r47122 r54559  
    14971497        if ( is_wp_error( $rss ) ) {
    14981498                if ( is_admin() || current_user_can( 'manage_options' ) ) {
    1499                         echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . $rss->get_error_message() . '</p>';
     1499                        echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . esc_html( $rss->get_error_message() ) . '</p>';
    15001500                }
    15011501                return;
     
    16201620
    16211621        if ( ! empty( $args['error'] ) ) {
    1622                 echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $args['error'] . '</p>';
     1622                echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . esc_html( $args['error'] ) . '</p>';
    16231623        }
    16241624
  • branches/5.4/src/wp-mail.php

    r47581 r54559  
    6565        wp_die( __( 'There doesn&#8217;t seem to be any new mail.' ) );
    6666}
     67
     68// Always run as an unauthenticated user.
     69wp_set_current_user( 0 );
    6770
    6871for ( $i = 1; $i <= $count; $i++ ) {
     
    132135                                $author = sanitize_email( $author );
    133136                                if ( is_email( $author ) ) {
    134                                         /* translators: %s: Post author email address. */
    135                                         echo '<p>' . sprintf( __( 'Author is %s' ), $author ) . '</p>';
    136137                                        $userdata = get_user_by( 'email', $author );
    137138                                        if ( ! empty( $userdata ) ) {
  • branches/5.4/src/wp-trackback.php

    r47198 r54559  
    1313        wp( array( 'tb' => '1' ) );
    1414}
     15
     16// Always run as an unauthenticated user.
     17wp_set_current_user( 0 );
    1518
    1619/**
  • branches/5.4/tests/phpunit/tests/query/search.php

    r47122 r54559  
    456456
    457457                add_post_meta( $attachment, '_wp_attached_file', 'some-image1.png', true );
    458                 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     458                add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
    459459
    460460                // Pass post_type a string value.
     
    486486
    487487                add_post_meta( $attachment, '_wp_attached_file', 'some-image2.png', true );
    488                 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     488                add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
    489489
    490490                // Pass post_type an array value.
     
    545545                add_post_meta( $attachment, '_wp_attached_file', 'some-image4.png', true );
    546546                add_post_meta( $attachment, '_test_meta_key', 'value', true );
    547                 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     547                add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
    548548
    549549                // Pass post_type a string value.
     
    585585
    586586                add_post_meta( $attachment, '_wp_attached_file', 'some-image5.png', true );
    587                 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     587                add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
    588588
    589589                // Pass post_type a string value.
     
    610610         * @ticket 22744
    611611         */
    612         public function test_filter_query_attachment_filenames_unhooks_itself() {
    613                 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
    614 
    615                 apply_filters(
    616                         'posts_clauses',
    617                         array(
    618                                 'where'    => '',
    619                                 'groupby'  => '',
    620                                 'join'     => '',
    621                                 'orderby'  => '',
    622                                 'distinct' => '',
    623                                 'fields'   => '',
    624                                 'limit'    => '',
    625                         )
    626                 );
    627 
    628                 $result = has_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
    629 
    630                 $this->assertFalse( $result );
     612        public function test_wp_query_removes_filter_wp_allow_query_attachment_by_filename() {
     613                $attachment = self::factory()->post->create(
     614                        array(
     615                                'post_type'    => 'attachment',
     616                                'post_status'  => 'publish',
     617                                'post_title'   => 'bar foo',
     618                                'post_content' => 'foo bar',
     619                                'post_excerpt' => 'This post has foo',
     620                        )
     621                );
     622
     623                add_post_meta( $attachment, '_wp_attached_file', 'some-image1.png', true );
     624                add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
     625
     626                $q = new WP_Query(
     627                        array(
     628                                's'           => 'image1',
     629                                'fields'      => 'ids',
     630                                'post_type'   => 'attachment',
     631                                'post_status' => 'inherit',
     632                        )
     633                );
     634
     635                $this->assertSame( array( $attachment ), $q->posts );
     636
     637                /*
     638                 * WP_Query should have removed the wp_allow_query_attachment_by_filename filter
     639                 * and thus not match the attachment created above
     640                 */
     641                $q->get_posts();
     642                $this->assertEmpty( $q->posts );
    631643        }
    632644
  • branches/5.4/tests/phpunit/tests/rest-api/rest-comments-controller.php

    r47122 r54559  
    28732873                                        'author_name'       => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    28742874                                        'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2875                                        'author'            => self::$editor_id,
    28752876                                ),
    28762877                                array(
     
    28812882                                        'author_name'       => 'div strong',
    28822883                                        'author_user_agent' => 'div strong',
     2884                                        'author'            => self::$editor_id,
    28832885                                )
    28842886                        );
     
    28902892                                        'author_name'       => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    28912893                                        'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2894                                        'author'            => self::$editor_id,
    28922895                                ),
    28932896                                array(
     
    28982901                                        'author_name'       => 'div strong',
    28992902                                        'author_user_agent' => 'div strong',
     2903                                        'author'            => self::$editor_id,
    29002904                                )
    29012905                        );
     
    29122916                                'author_name'       => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    29132917                                'author_user_agent' => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     2918                                'author'            => self::$superadmin_id,
    29142919                        ),
    29152920                        array(
     
    29202925                                'author_name'       => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
    29212926                                'author_user_agent' => '\\\&\\\ &amp; &invalid; &lt; &lt; &amp;lt;',
     2927                                'author'            => self::$superadmin_id,
    29222928                        )
    29232929                );
     
    29332939                                'author_name'       => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    29342940                                'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2941                                'author'            => self::$superadmin_id,
    29352942                        ),
    29362943                        array(
     
    29412948                                'author_name'       => 'div strong',
    29422949                                'author_user_agent' => 'div strong',
     2950                                'author'            => self::$superadmin_id,
    29432951                        )
    29442952                );
Note: See TracChangeset for help on using the changeset viewer.