Make WordPress Core

Ticket #31025: 31025.diff

File 31025.diff, 8.3 KB (added by swissspidy, 10 years ago)
  • src/wp-admin/edit-comments.php

    diff --git src/wp-admin/edit-comments.php src/wp-admin/edit-comments.php
    index 3aac00b..218b5b8 100644
    if ( $post_id ) 
    186186else
    187187        _e( 'Comments' );
    188188
    189 if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
    190         echo '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '&hellip;' ) ) . '</span>'; ?>
     189if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) {
     190        echo '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '&hellip;' ) ) . '</span>';
     191}
     192?>
    191193</h1>
    192194
    193195<?php
  • src/wp-admin/edit-tags.php

    diff --git src/wp-admin/edit-tags.php src/wp-admin/edit-tags.php
    index 748ae17..80595a6 100644
    if ( is_plugin_active( 'wpcat2tag-importer/wpcat2tag-importer.php' ) ) { 
    307307
    308308<div class="wrap nosubsub">
    309309<h1><?php echo esc_html( $title );
    310 if ( !empty($_REQUEST['s']) )
    311         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( wp_unslash($_REQUEST['s']) ) ); ?>
     310if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) {
     311        printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) );
     312}
     313?>
    312314</h1>
    313315
    314316<?php if ( $message ) : ?>
  • src/wp-admin/edit.php

    diff --git src/wp-admin/edit.php src/wp-admin/edit.php
    index fa4a7b6..b46d1d0 100644
    require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
    303303echo esc_html( $post_type_object->labels->name );
    304304if ( current_user_can( $post_type_object->cap->create_posts ) )
    305305        echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>';
    306 if ( ! empty( $_REQUEST['s'] ) )
    307         printf( ' <span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() );
     306
     307if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) {
     308        printf( ' <span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', get_search_query() );
     309}
    308310?></h1>
    309311
    310312<?php
  • src/wp-admin/link-manager.php

    diff --git src/wp-admin/link-manager.php src/wp-admin/link-manager.php
    index 5cf80cd..d6bb18d 100644
    if ( ! current_user_can('manage_links') ) 
    7474
    7575<div class="wrap nosubsub">
    7676<h1><?php echo esc_html( $title ); ?> <a href="link-add.php" class="page-title-action"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php
    77 if ( !empty($_REQUEST['s']) )
    78         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( wp_unslash($_REQUEST['s']) ) ); ?>
     77if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) {
     78        printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) );
     79}
     80?>
    7981</h1>
    8082
    8183<?php
  • src/wp-admin/network/sites.php

    diff --git src/wp-admin/network/sites.php src/wp-admin/network/sites.php
    index e0e7e1e..1ec328c 100644
    require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
    284284        <a href="<?php echo network_admin_url('site-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
    285285<?php endif; ?>
    286286
    287 <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) {
     287<?php
     288if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) {
    288289        printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
    289290} ?>
    290291</h1>
  • src/wp-admin/network/themes.php

    diff --git src/wp-admin/network/themes.php src/wp-admin/network/themes.php
    index 958bd7e..057dd1e 100644
    require_once(ABSPATH . 'wp-admin/admin-header.php'); 
    268268
    269269<div class="wrap">
    270270<h1><?php echo esc_html( $title ); if ( current_user_can('install_themes') ) { ?> <a href="theme-install.php" class="page-title-action"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php }
    271 if ( $s )
    272         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) ); ?>
     271if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) {
     272        printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
     273}
     274?>
    273275</h1>
    274276
    275277<?php
  • src/wp-admin/network/users.php

    diff --git src/wp-admin/network/users.php src/wp-admin/network/users.php
    index f55ea6c..36094eb 100644
    if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( 
    212212                <a href="<?php echo network_admin_url('user-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a><?php
    213213        endif;
    214214
    215         if ( !empty( $usersearch ) )
    216         printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $usersearch ) );
     215        if ( '' !== $usersearch ) {
     216                printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $usersearch ) );
     217        }
    217218        ?>
    218219        </h1>
    219220
  • src/wp-admin/plugins.php

    diff --git src/wp-admin/plugins.php src/wp-admin/plugins.php
    index 93aec79..24728af 100644
    if ( ! empty( $invalid ) ) { 
    510510<h1><?php echo esc_html( $title );
    511511if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plugins') ) { ?>
    512512 <a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="page-title-action"><?php echo esc_html_x('Add New', 'plugin'); ?></a>
    513 <?php }
    514 if ( $s )
    515         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) ); ?>
     513<?php
     514}
     515
     516if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) {
     517        printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
     518}
     519?>
    516520</h1>
    517521
    518522<?php
  • src/wp-admin/upload.php

    diff --git src/wp-admin/upload.php src/wp-admin/upload.php
    index 65bb790..524432d 100644
    echo esc_html( $title ); 
    220220if ( current_user_can( 'upload_files' ) ) { ?>
    221221        <a href="media-new.php" class="page-title-action"><?php echo esc_html_x('Add New', 'file'); ?></a><?php
    222222}
    223 if ( ! empty( $_REQUEST['s'] ) )
    224         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() ); ?>
     223if ( isset( $_REQUEST['s'] ) && '' !== $_REQUEST['s'] ) {
     224        printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', get_search_query() );
     225}
     226?>
    225227</h1>
    226228
    227229<?php
  • src/wp-admin/users.php

    diff --git src/wp-admin/users.php src/wp-admin/users.php
    index a541baf..359f1db 100644
    if ( current_user_can( 'create_users' ) ) { ?> 
    475475        <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
    476476<?php }
    477477
    478 if ( $usersearch )
    479         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $usersearch ) ); ?>
     478if ( '' !== $usersearch ) {
     479        printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $usersearch ) );
     480}
     481?>
    480482</h1>
    481483
    482484<?php $wp_list_table->views(); ?>
  • src/wp-includes/query.php

    diff --git src/wp-includes/query.php src/wp-includes/query.php
    index 84eda07..a874151 100644
    class WP_Query { 
    27932793                }
    27942794
    27952795                // If a search pattern is specified, load the posts that match.
    2796                 if ( ! empty( $q['s'] ) ) {
     2796                if ( isset( $q['s'] ) ) {
    27972797                        $search = $this->parse_search( $q );
    27982798                }
    27992799
  • tests/phpunit/tests/query/search.php

    diff --git tests/phpunit/tests/query/search.php tests/phpunit/tests/query/search.php
    index b81bef3..f49d023 100644
    class Tests_Query_Search extends WP_UnitTestCase { 
    125125
    126126                $this->assertEqualSets( array( $p3 ), $q->posts );
    127127        }
     128
     129        /**
     130         * @ticket 31025
     131         */
     132        public function test_s_zero() {
     133                $p = $this->factory->post->create( array(
     134                        'post_status' => 'publish',
     135                        'post_title' => '0',
     136                ) );
     137
     138                $q = new WP_Query( array(
     139                        's' => '0',
     140                        'fields' => 'ids',
     141                ) );
     142
     143                $this->assertEqualSets( array( $p ), $q->posts );
     144        }
    128145}