Make WordPress Core

Changeset 54555


Ignore:
Timestamp:
10/17/2022 05:56:34 PM (21 months ago)
Author:
audrasjb
Message:

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

Legend:

Unmodified
Added
Removed
  • branches/5.6

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

    r49193 r54555  
    29762976    // Filter query clauses to include filenames.
    29772977    if ( isset( $query['s'] ) ) {
    2978         add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     2978        add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
    29792979    }
    29802980
  • branches/5.6/src/wp-admin/includes/post.php

    r49732 r54555  
    12701270    // Filter query clauses to include filenames.
    12711271    if ( isset( $q['s'] ) ) {
    1272         add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     1272        add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
    12731273    }
    12741274
  • branches/5.6/src/wp-includes/class-wp-date-query.php

    r49108 r54555  
    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';
     
    219219            $this->validate_date_values( $queries );
    220220        }
     221
     222        // Sanitize the relation parameter.
     223        $queries['relation'] = $this->sanitize_relation( $queries['relation'] );
    221224
    222225        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.6/src/wp-includes/class-wp-query.php

    r49506 r54555  
    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.
     
    13921399
    13931400            $like      = $n . $wpdb->esc_like( $term ) . $n;
    1394             $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 );
     1401
     1402            if ( ! empty( $this->allow_query_attachment_by_filename ) ) {
     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) $andor_op (sq1.meta_value $like_op %s))", $like, $like, $like, $like );
     1404            } else {
     1405                $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 );
     1406            }
    13951407            $searchand = ' AND ';
    13961408        }
     
    17851797        $q = $this->fill_query_vars( $q );
    17861798
     1799        /**
     1800         * Filters whether an attachment query should include filenames or not.
     1801         *
     1802         * @since 6.0.3
     1803         *
     1804         * @param bool $allow_query_attachment_by_filename Whether or not to include filenames.
     1805         */
     1806        $this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false );
     1807        remove_all_filters( 'wp_allow_query_attachment_by_filename' );
     1808
    17871809        // Parse meta query.
    17881810        $this->meta_query = new WP_Meta_Query();
     
    22162238        }
    22172239
    2218         if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) ) {
     2240        if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) || ! empty( $this->allow_query_attachment_by_filename ) ) {
    22192241            $groupby = "{$wpdb->posts}.ID";
    22202242        }
     
    22922314        }
    22932315        $where .= $search . $whichauthor . $whichmimetype;
     2316
     2317        if ( ! empty( $this->allow_query_attachment_by_filename ) ) {
     2318            $join .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
     2319        }
    22942320
    22952321        if ( ! empty( $this->meta_query->queries ) ) {
  • branches/5.6/src/wp-includes/comment.php

    r49215 r54555  
    24602460    }
    24612461
     2462    $filter_comment = false;
     2463    if ( ! has_filter( 'pre_comment_content', 'wp_filter_kses' ) ) {
     2464        $filter_comment = ! user_can( isset( $comment['user_id'] ) ? $comment['user_id'] : 0, 'unfiltered_html' );
     2465    }
     2466
     2467    if ( $filter_comment ) {
     2468        add_filter( 'pre_comment_content', 'wp_filter_kses' );
     2469    }
     2470
    24622471    // Escape data pulled from DB.
    24632472    $comment = wp_slash( $comment );
     
    24692478
    24702479    $commentarr = wp_filter_comment( $commentarr );
     2480
     2481    if ( $filter_comment ) {
     2482        remove_filter( 'pre_comment_content', 'wp_filter_kses' );
     2483    }
    24712484
    24722485    // Now extract the merged array.
  • branches/5.6/src/wp-includes/customize/class-wp-customize-header-image-control.php

    r48834 r54555  
    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
     
    159159                <# } else { #>
    160160
    161             <img src="{{{data.header.thumbnail_url}}}" alt="{{{data.header.alt_text || data.header.description}}}" />
     161            <img src="{{data.header.thumbnail_url}}" alt="{{data.header.alt_text || data.header.description}}" />
    162162
    163163                <# } #>
  • branches/5.6/src/wp-includes/customize/class-wp-customize-site-icon-control.php

    r47382 r54555  
    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.6/src/wp-includes/deprecated.php

    r49597 r54555  
    41364136    return is_string( $value ) ? addslashes( $value ) : $value;
    41374137}
     4138
     4139/**
     4140 * Filter the SQL clauses of an attachment query to include filenames.
     4141 *
     4142 * @since 4.7.0
     4143 * @deprecated 6.0.3
     4144 * @access private
     4145 *
     4146 * @param array $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY,
     4147 *                       DISTINCT, fields (SELECT), and LIMITS clauses.
     4148 * @return array The unmodified clauses.
     4149 */
     4150function _filter_query_attachment_filenames( $clauses ) {
     4151    _deprecated_function( __FUNCTION__, '6.0.3', 'add_filter( "wp_allow_query_attachment_by_filename", "__return_true" )');
     4152    remove_filter( 'posts_clauses', __FUNCTION__ );
     4153    return $clauses;
     4154}
     4155
  • branches/5.6/src/wp-includes/functions.php

    r51743 r54555  
    32883288        $html = __( 'The link you followed has expired.' );
    32893289        if ( wp_get_referer() ) {
     3290            $wp_http_referer = remove_query_arg( 'updated', wp_get_referer() );
     3291            $wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) );
    32903292            $html .= '</p><p>';
    32913293            $html .= sprintf(
    32923294                '<a href="%s">%s</a>',
    3293                 esc_url( remove_query_arg( 'updated', wp_get_referer() ) ),
     3295                esc_url( $wp_http_referer ),
    32943296                __( 'Please try again.' )
    32953297            );
  • branches/5.6/src/wp-includes/media-template.php

    r49820 r54555  
    14941494                <img id="preview-favicon" src="{{ data.url }}" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/>
    14951495            </div>
    1496             <span class="browser-title" aria-hidden="true"><# print( '<?php bloginfo( 'name' ); ?>' ) #></span>
     1496            <span class="browser-title" aria-hidden="true"><# print( '<?php echo esc_js( get_bloginfo( 'name' ) ); ?>' ) #></span>
    14971497        </div>
    14981498
  • branches/5.6/src/wp-includes/pluggable.php

    r49193 r54555  
    318318        $phpmailer->clearCustomHeaders();
    319319        $phpmailer->clearReplyTos();
     320        $phpmailer->Body    = '';
     321        $phpmailer->AltBody = '';
    320322
    321323        // Set "From" name and email.
  • branches/5.6/src/wp-includes/post.php

    r52467 r54555  
    19881988 * @since 4.5.0 Added the ability to pass a post type name in addition to object.
    19891989 * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
     1990 * @since 5.9.0 Added `is_post_type_viewable` hook to filter the result.
    19901991 *
    19911992 * @param string|WP_Post_Type $post_type Post type name or object.
     
    19951996    if ( is_scalar( $post_type ) ) {
    19961997        $post_type = get_post_type_object( $post_type );
     1998
    19971999        if ( ! $post_type ) {
    19982000            return false;
     
    20002002    }
    20012003
    2002     return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
     2004    if ( ! is_object( $post_type ) ) {
     2005        return false;
     2006    }
     2007
     2008    $is_viewable = $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
     2009
     2010    /**
     2011     * Filters whether a post type is considered "viewable".
     2012     *
     2013     * The returned filtered value must be a boolean type to ensure
     2014     * `is_post_type_viewable()` only returns a boolean. This strictness
     2015     * is by design to maintain backwards-compatibility and guard against
     2016     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     2017     * and truthy values) will result in the function returning false.
     2018     *
     2019     * @since 5.9.0
     2020     *
     2021     * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
     2022     * @param WP_Post_Type $post_type   Post type object.
     2023     */
     2024    return true === apply_filters( 'is_post_type_viewable', $is_viewable, $post_type );
     2025}
     2026
     2027/**
     2028 * Determines whether a post status is considered "viewable".
     2029 *
     2030 * For built-in post statuses such as publish and private, the 'public' value will be evaluated.
     2031 * For all others, the 'publicly_queryable' value will be used.
     2032 *
     2033 * @since 5.7.0
     2034 * @since 5.9.0 Added `is_post_status_viewable` hook to filter the result.
     2035 *
     2036 * @param string|stdClass $post_status Post status name or object.
     2037 * @return bool Whether the post status should be considered viewable.
     2038 */
     2039function is_post_status_viewable( $post_status ) {
     2040    if ( is_scalar( $post_status ) ) {
     2041        $post_status = get_post_status_object( $post_status );
     2042
     2043        if ( ! $post_status ) {
     2044            return false;
     2045        }
     2046    }
     2047
     2048    if (
     2049        ! is_object( $post_status ) ||
     2050        $post_status->internal ||
     2051        $post_status->protected
     2052    ) {
     2053        return false;
     2054    }
     2055
     2056    $is_viewable = $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public );
     2057
     2058    /**
     2059     * Filters whether a post status is considered "viewable".
     2060     *
     2061     * The returned filtered value must be a boolean type to ensure
     2062     * `is_post_status_viewable()` only returns a boolean. This strictness
     2063     * is by design to maintain backwards-compatibility and guard against
     2064     * potential type errors in PHP 8.1+. Non-boolean values (even falsey
     2065     * and truthy values) will result in the function returning false.
     2066     *
     2067     * @since 5.9.0
     2068     *
     2069     * @param bool     $is_viewable Whether the post status is "viewable" (strict type).
     2070     * @param stdClass $post_status Post status object.
     2071     */
     2072    return true === apply_filters( 'is_post_status_viewable', $is_viewable, $post_status );
     2073}
     2074
     2075/**
     2076 * Determines whether a post is publicly viewable.
     2077 *
     2078 * Posts are considered publicly viewable if both the post status and post type
     2079 * are viewable.
     2080 *
     2081 * @since 5.7.0
     2082 *
     2083 * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
     2084 * @return bool Whether the post is publicly viewable.
     2085 */
     2086function is_post_publicly_viewable( $post = null ) {
     2087    $post = get_post( $post );
     2088
     2089    if ( ! $post ) {
     2090        return false;
     2091    }
     2092
     2093    $post_type   = get_post_type( $post );
     2094    $post_status = get_post_status( $post );
     2095
     2096    return is_post_type_viewable( $post_type ) && is_post_status_viewable( $post_status );
    20032097}
    20042098
     
    74767570
    74777571/**
    7478  * Filters the SQL clauses of an attachment query to include filenames.
    7479  *
    7480  * @since 4.7.0
    7481  * @access private
    7482  *
    7483  * @global wpdb $wpdb WordPress database abstraction object.
    7484  *
    7485  * @param string[] $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY,
    7486  *                          DISTINCT, fields (SELECT), and LIMITS clauses.
    7487  * @return string[] The modified array of clauses.
    7488  */
    7489 function _filter_query_attachment_filenames( $clauses ) {
    7490     global $wpdb;
    7491     remove_filter( 'posts_clauses', __FUNCTION__ );
    7492 
    7493     // Add a LEFT JOIN of the postmeta table so we don't trample existing JOINs.
    7494     $clauses['join'] .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
    7495 
    7496     $clauses['groupby'] = "{$wpdb->posts}.ID";
    7497 
    7498     $clauses['where'] = preg_replace(
    7499         "/\({$wpdb->posts}.post_content (NOT LIKE|LIKE) (\'[^']+\')\)/",
    7500         '$0 OR ( sq1.meta_value $1 $2 )',
    7501         $clauses['where']
    7502     );
    7503 
    7504     return $clauses;
    7505 }
    7506 
    7507 /**
    75087572 * Sets the last changed time for the 'posts' cache group.
    75097573 *
  • branches/5.6/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    r49732 r54555  
    9090        // Filter query clauses to include filenames.
    9191        if ( isset( $query_args['s'] ) ) {
    92             add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     92            add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
    9393        }
    9494
  • branches/5.6/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    r50047 r54555  
    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.6/src/wp-includes/widgets.php

    r49561 r54555  
    15231523    if ( is_wp_error( $rss ) ) {
    15241524        if ( is_admin() || current_user_can( 'manage_options' ) ) {
    1525             echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . $rss->get_error_message() . '</p>';
     1525            echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . esc_html( $rss->get_error_message() ) . '</p>';
    15261526        }
    15271527        return;
     
    16461646
    16471647    if ( ! empty( $args['error'] ) ) {
    1648         echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $args['error'] . '</p>';
     1648        echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . esc_html( $args['error'] ) . '</p>';
    16491649    }
    16501650
  • branches/5.6/src/wp-mail.php

    r47580 r54555  
    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.6/src/wp-trackback.php

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

    r48939 r54555  
    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.6/tests/phpunit/tests/rest-api/rest-comments-controller.php

    r49603 r54555  
    29732973                    'author_name'       => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    29742974                    'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2975                    'author'            => self::$editor_id,
    29752976                ),
    29762977                array(
     
    29812982                    'author_name'       => 'div strong',
    29822983                    'author_user_agent' => 'div strong',
     2984                    'author'            => self::$editor_id,
    29832985                )
    29842986            );
     
    29902992                    'author_name'       => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    29912993                    'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     2994                    'author'            => self::$editor_id,
    29922995                ),
    29932996                array(
     
    29983001                    'author_name'       => 'div strong',
    29993002                    'author_user_agent' => 'div strong',
     3003                    'author'            => self::$editor_id,
    30003004                )
    30013005            );
     
    30123016                'author_name'       => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    30133017                'author_user_agent' => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     3018                'author'            => self::$superadmin_id,
    30143019            ),
    30153020            array(
     
    30203025                'author_name'       => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
    30213026                'author_user_agent' => '\\\&\\\ &amp; &invalid; &lt; &lt; &amp;lt;',
     3027                'author'            => self::$superadmin_id,
    30223028            )
    30233029        );
     
    30333039                'author_name'       => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    30343040                'author_user_agent' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
     3041                'author'            => self::$superadmin_id,
    30353042            ),
    30363043            array(
     
    30413048                'author_name'       => 'div strong',
    30423049                'author_user_agent' => 'div strong',
     3050                'author'            => self::$superadmin_id,
    30433051            )
    30443052        );
Note: See TracChangeset for help on using the changeset viewer.