Make WordPress Core

Changeset 54548

Timestamp:
10/17/2022 05:46:39 PM (22 months ago)
Author:
audrasjb
Message:

Grouped backports to the 5.8 branch.

  • Editor: Bump @wordpress packages for the 5.9 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,
  • Users: Revert use of shared objects for current user,
  • 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.8 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.8
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • branches/5.8

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

    r51983 r54548  
    29752975    // Filter query clauses to include filenames.
    29762976    if ( isset( $query['s'] ) ) {
    2977         add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     2977        add_filter( '' );
    29782978    }
    29792979
  • branches/5.8/src/wp-admin/includes/post.php

    r51116 r54548  
    12851285    // Filter query clauses to include filenames.
    12861286    if ( isset( $q['s'] ) ) {
    1287         add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     1287        add_filter( '' );
    12881288    }
    12891289
  • branches/5.8/src/wp-includes/class-wp-date-query.php

    r49672 r54548  
    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 = ;
    154154        } else {
    155155            $this->relation = 'AND';
     
    219219            $this->validate_date_values( $queries );
    220220        }
     221
     222
     223
    221224
    222225        foreach ( $queries as $key => $q ) {
     
    10401043        return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time );
    10411044    }
     1045
     1046
     1047
     1048
     1049
     1050
     1051
     1052
     1053
     1054
     1055
     1056
     1057
     1058
     1059
     1060
    10421061}
  • branches/5.8/src/wp-includes/class-wp-query.php

    r50576 r54548  
    445445    public $thumbnails_cached = false;
    446446
     447
     448
     449
     450
     451
     452
     453
    447454    /**
    448455     * Cached list of search stopwords.
     
    13951402
    13961403            $like      = $n . $wpdb->esc_like( $term ) . $n;
    1397             $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
     1405            if ( ! empty( $this->allow_query_attachment_by_filename ) ) {
     1406                $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 );
     1407            } else {
     1408                $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 );
     1409            }
    13981410            $searchand = ' AND ';
    13991411        }
     
    17901802        $q = $this->fill_query_vars( $q );
    17911803
     1804
     1805
     1806
     1807
     1808
     1809
     1810
     1811
     1812
     1813
    17921814        // Parse meta query.
    17931815        $this->meta_query = new WP_Meta_Query();
     
    22212243        }
    22222244
    2223         if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) ) {
     2245        if ( ! empty( $this->tax_query->queries ) || ! empty( $this->meta_query->queries ) ) {
    22242246            $groupby = "{$wpdb->posts}.ID";
    22252247        }
     
    22972319        }
    22982320        $where .= $search . $whichauthor . $whichmimetype;
     2321
     2322
     2323
     2324
    22992325
    23002326        if ( ! empty( $this->meta_query->queries ) ) {
  • branches/5.8/src/wp-includes/comment.php

    r50641 r54548  
    24672467    }
    24682468
     2469
     2470
     2471
     2472
     2473
     2474
     2475
     2476
     2477
    24692478    // Escape data pulled from DB.
    24702479    $comment = wp_slash( $comment );
     
    24762485
    24772486    $commentarr = wp_filter_comment( $commentarr );
     2487
     2488
     2489
     2490
    24782491
    24792492    // Now extract the merged array.
  • branches/5.8/src/wp-includes/customize/class-wp-customize-header-image-control.php

    r48834 r54548  
    131131
    132132            <button type="button" class="choice thumbnail"
    133                 data-customize-image-value="{{{data.header.url}}}"
     133                data-customize-image-value="{{}}"
    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="{{}}" />
    137137            </button>
    138138
     
    159159                <# } else { #>
    160160
    161             <img src="{{{data.header.thumbnail_url}}}" alt="{{{data.header.alt_text || data.header.description}}}" />
     161            <img src="{{}}" />
    162162
    163163                <# } #>
  • branches/5.8/src/wp-includes/customize/class-wp-customize-site-icon-control.php

    r50556 r54548  
    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 ); ?>' ) #></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.8/src/wp-includes/deprecated.php

    r51382 r54548  
    42254225    return _excerpt_render_inner_blocks( $columns, $allowed_blocks );
    42264226}
     4227
     4228
     4229
     4230
     4231
     4232
     4233
     4234
     4235
     4236
     4237
     4238
     4239
     4240
     4241
     4242
     4243
     4244
  • branches/5.8/src/wp-includes/functions.php

    r51741 r54548  
    34673467        $html = __( 'The link you followed has expired.' );
    34683468        if ( wp_get_referer() ) {
     3469
     3470
    34693471            $html .= '</p><p>';
    34703472            $html .= sprintf(
    34713473                '<a href="%s">%s</a>',
    3472                 esc_url( remove_query_arg( 'updated', wp_get_referer() ) ),
     3474                esc_url( ),
    34733475                __( 'Please try again.' )
    34743476            );
  • branches/5.8/src/wp-includes/media-template.php

    r50556 r54548  
    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 ); ?>' ) #></span>
    14971497        </div>
    14981498
  • branches/5.8/src/wp-includes/pluggable.php

    r50952 r54548  
    9292     * @since 2.8.0
    9393     * @since 4.4.0 Added 'ID' as an alias of 'id' for the `$field` parameter.
    94      * @since 5.8.0 Returns the global `$current_user` if it's the user being fetched.
    9594     *
    9695     * @global WP_User $current_user The current user object which holds the user data.
     
    101100     */
    102101    function get_user_by( $field, $value ) {
    103         global $current_user;
    104 
    105102        $userdata = WP_User::get_data_by( $field, $value );
    106103
    107104        if ( ! $userdata ) {
    108105            return false;
    109         }
    110 
    111         if ( $current_user instanceof WP_User && $current_user->ID === (int) $userdata->ID ) {
    112             return $current_user;
    113106        }
    114107
     
    362355        $phpmailer->clearCustomHeaders();
    363356        $phpmailer->clearReplyTos();
     357
     358
    364359
    365360        // Set "From" name and email.
  • branches/5.8/src/wp-includes/post.php

    r52465 r54548  
    76967696
    76977697/**
    7698  * Filters the SQL clauses of an attachment query to include filenames.
    7699  *
    7700  * @since 4.7.0
    7701  * @access private
    7702  *
    7703  * @global wpdb $wpdb WordPress database abstraction object.
    7704  *
    7705  * @param string[] $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY,
    7706  *                          DISTINCT, fields (SELECT), and LIMITS clauses.
    7707  * @return string[] The modified array of clauses.
    7708  */
    7709 function _filter_query_attachment_filenames( $clauses ) {
    7710     global $wpdb;
    7711     remove_filter( 'posts_clauses', __FUNCTION__ );
    7712 
    7713     // Add a LEFT JOIN of the postmeta table so we don't trample existing JOINs.
    7714     $clauses['join'] .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";
    7715 
    7716     $clauses['groupby'] = "{$wpdb->posts}.ID";
    7717 
    7718     $clauses['where'] = preg_replace(
    7719         "/\({$wpdb->posts}.post_content (NOT LIKE|LIKE) (\'[^']+\')\)/",
    7720         '$0 OR ( sq1.meta_value $1 $2 )',
    7721         $clauses['where']
    7722     );
    7723 
    7724     return $clauses;
    7725 }
    7726 
    7727 /**
    77287698 * Sets the last changed time for the 'posts' cache group.
    77297699 *
  • branches/5.8/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    r51000 r54548  
    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( '' );
    9393        }
    9494
  • branches/5.8/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    r51295 r54548  
    136136
    137137    /**
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     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
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
    158211        }
    159212
  • branches/5.8/src/wp-includes/user.php

    r51411 r54548  
    15721572 * @since 3.0.0
    15731573 * @since 4.4.0 'clean_user_cache' action was added.
    1574  * @since 5.8.0 Refreshes the global user instance if cleaning the user cache for the current user.
    1575  *
    1576  * @global WP_User $current_user The current user object which holds the user data.
    15771574 *
    15781575 * @param WP_User|int $user User object or ID to be cleaned from the cache
    15791576 */
    15801577function clean_user_cache( $user ) {
    1581     global $current_user;
    1582 
    15831578    if ( is_numeric( $user ) ) {
    15841579        $user = new WP_User( $user );
     
    16031598     */
    16041599    do_action( 'clean_user_cache', $user->ID, $user );
    1605 
    1606     // Refresh the global user instance if the cleaning current user.
    1607     if ( get_current_user_id() === (int) $user->ID ) {
    1608         $user_id      = (int) $user->ID;
    1609         $current_user = null;
    1610         wp_set_current_user( $user_id, '' );
    1611     }
    16121600}
    16131601
  • branches/5.8/src/wp-includes/widgets.php

    r51394 r54548  
    15351535    if ( is_wp_error( $rss ) ) {
    15361536        if ( is_admin() || current_user_can( 'manage_options' ) ) {
    1537             echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . $rss->get_error_message() . '</p>';
     1537            echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . ) . '</p>';
    15381538        }
    15391539        return;
     
    16581658
    16591659    if ( ! empty( $args['error'] ) ) {
    1660         echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $args['error'] . '</p>';
     1660        echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . . '</p>';
    16611661    }
    16621662
  • branches/5.8/src/wp-mail.php

    r47580 r54548  
    6565    wp_die( __( 'There doesn&#8217;t seem to be any new mail.' ) );
    6666}
     67
     68
     69
    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.8/src/wp-trackback.php

    r49108 r54548  
    1313    wp( array( 'tb' => '1' ) );
    1414}
     15
     16
     17
    1518
    1619/**
  • branches/5.8/tests/phpunit/tests/pluggable.php

    r50916 r54548  
    324324        return $signatures;
    325325    }
    326 
    327     /**
    328      * @ticket 28020
    329      */
    330     public function test_get_user_by_should_return_same_instance_as_wp_get_current_user() {
    331         // Create a test user.
    332         $new_user = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    333 
    334         // Set the test user as the current user.
    335         $current_user = wp_set_current_user( $new_user );
    336 
    337         // Get the test user using get_user_by().
    338         $from_get_user_by = get_user_by( 'id', $new_user );
    339 
    340         $this->assertSame( $current_user, $from_get_user_by );
    341     }
    342326}
  • branches/5.8/tests/phpunit/tests/query/search.php

    r50463 r54548  
    455455
    456456        add_post_meta( $attachment, '_wp_attached_file', 'some-image1.png', true );
    457         add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     457        add_filter( '' );
    458458
    459459        // Pass post_type a string value.
     
    485485
    486486        add_post_meta( $attachment, '_wp_attached_file', 'some-image2.png', true );
    487         add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     487        add_filter( '' );
    488488
    489489        // Pass post_type an array value.
     
    544544        add_post_meta( $attachment, '_wp_attached_file', 'some-image4.png', true );
    545545        add_post_meta( $attachment, '_test_meta_key', 'value', true );
    546         add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     546        add_filter( '' );
    547547
    548548        // Pass post_type a string value.
     
    584584
    585585        add_post_meta( $attachment, '_wp_attached_file', 'some-image5.png', true );
    586         add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
     586        add_filter( '' );
    587587
    588588        // Pass post_type a string value.
     
    609609     * @ticket 22744
    610610     */
    611     public function test_filter_query_attachment_filenames_unhooks_itself() {
    612         add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
    613 
    614         apply_filters(
    615             'posts_clauses',
    616             array(
    617                 'where'    => '',
    618                 'groupby'  => '',
    619                 'join'     => '',
    620                 'orderby'  => '',
    621                 'distinct' => '',
    622                 'fields'   => '',
    623                 'limit'    => '',
    624             )
    625         );
    626 
    627         $result = has_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
    628 
    629         $this->assertFalse( $result );
     611    public function test_wp_query_removes_filter_wp_allow_query_attachment_by_filename() {
     612        $attachment = self::factory()->post->create(
     613            array(
     614                'post_type'    => 'attachment',
     615                'post_status'  => 'publish',
     616                'post_title'   => 'bar foo',
     617                'post_content' => 'foo bar',
     618                'post_excerpt' => 'This post has foo',
     619            )
     620        );
     621
     622        add_post_meta( $attachment, '_wp_attached_file', 'some-image1.png', true );
     623        add_filter( 'wp_allow_query_attachment_by_filename', '__return_true' );
     624
     625        $q = new WP_Query(
     626            array(
     627                's'           => 'image1',
     628                'fields'      => 'ids',
     629                'post_type'   => 'attachment',
     630                'post_status' => 'inherit',
     631            )
     632        );
     633
     634        $this->assertSame( array( $attachment ), $q->posts );
     635
     636        /*
     637         * WP_Query should have removed the wp_allow_query_attachment_by_filename filter
     638         * and thus not match the attachment created above
     639         */
     640        $q->get_posts();
     641        $this->assertEmpty( $q->posts );
    630642    }
    631643
  • branches/5.8/tests/phpunit/tests/rest-api/rest-comments-controller.php

    r49603 r54548  
    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
    29752976                ),
    29762977                array(
     
    29812982                    'author_name'       => 'div strong',
    29822983                    'author_user_agent' => 'div strong',
     2984
    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
    29922995                ),
    29932996                array(
     
    29983001                    'author_name'       => 'div strong',
    29993002                    'author_user_agent' => 'div strong',
     3003
    30003004                )
    30013005            );
     
    30123016                'author_name'       => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    30133017                'author_user_agent' => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
     3018
    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
    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
    30353042            ),
    30363043            array(
     
    30413048                'author_name'       => 'div strong',
    30423049                'author_user_agent' => 'div strong',
     3050
    30433051            )
    30443052        );
Note: See TracChangeset for help on using the changeset viewer.