Skip to content

[51926] Network Site Search should search more than just wp_blogs.path #8922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions src/wp-admin/includes/class-wp-ms-sites-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ public function prepare_items() {
$args['ID'] = $s;
} else {
$args['search'] = $s;

if ( ! is_subdomain_install() ) {
$args['search_columns'] = array( 'path' );
}
}

$order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
Expand All @@ -141,11 +137,7 @@ public function prepare_items() {
} elseif ( 'lastupdated' === $order_by ) {
$order_by = 'last_updated';
} elseif ( 'blogname' === $order_by ) {
if ( is_subdomain_install() ) {
$order_by = 'domain';
} else {
$order_by = 'path';
}
$order_by = 'domain path';
} elseif ( 'blog_id' === $order_by ) {
$order_by = 'id';
} elseif ( ! $order_by ) {
Expand Down
54 changes: 32 additions & 22 deletions tests/phpunit/tests/multisite/wpMsSitesListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
'domain' => 'atest.example.org',
'path' => '/',
),
'foo.example.com/' => array(
'domain' => 'foo.example.com',
'path' => '/',
),
);

foreach ( self::$site_ids as &$id ) {
Expand All @@ -96,11 +100,7 @@ public function test_ms_sites_list_table_default_items() {
$this->assertSameSets( array( 1 ) + self::$site_ids, $items );
}

public function test_ms_sites_list_table_subdirectory_path_search_items() {
if ( is_subdomain_install() ) {
$this->markTestSkipped( 'Path search is not available for subdomain configurations.' );
}

public function test_ms_sites_list_table_search_items() {
$_REQUEST['s'] = 'foo';

$this->table->prepare_items();
Expand All @@ -117,16 +117,37 @@ public function test_ms_sites_list_table_subdirectory_path_search_items() {
self::$site_ids['make.wordpress.org/foo/'],
self::$site_ids['www.w.org/foo/'],
self::$site_ids['www.w.org/foo/bar/'],
self::$site_ids['foo.example.com/'],
);

$this->assertSameSets( $expected, $items );
}

public function test_ms_sites_list_table_subdirectory_multiple_path_search_items() {
if ( is_subdomain_install() ) {
$this->markTestSkipped( 'Path search is not available for subdomain configurations.' );
}
public function test_ms_sites_list_table_orderby_blogname() {
$_REQUEST['s'] = 'foo';
$_REQUEST['orderby'] = 'blogname';

$this->table->prepare_items();

$items = wp_list_pluck( $this->table->items, 'blog_id' );
$items = array_map( 'intval', $items );

unset( $_REQUEST['s'] );

$expected = array(
self::$site_ids['foo.example.com/'],
self::$site_ids['make.wordpress.org/foo/'],
self::$site_ids['wordpress.org/afoo/'],
self::$site_ids['wordpress.org/foo/'],
self::$site_ids['wordpress.org/foo/bar/'],
self::$site_ids['www.w.org/foo/'],
self::$site_ids['www.w.org/foo/bar/'],
);

$this->assertSameSets( $expected, $items );
}

public function test_ms_sites_list_table_multiple_path_search_items() {
$_REQUEST['s'] = 'foo/bar';

$this->table->prepare_items();
Expand All @@ -144,7 +165,7 @@ public function test_ms_sites_list_table_subdirectory_multiple_path_search_items
$this->assertSameSets( $expected, $items );
}

public function test_ms_sites_list_table_invalid_path_search_items() {
public function test_ms_sites_list_table_invalid_search_items() {
$_REQUEST['s'] = 'foobar';

$this->table->prepare_items();
Expand All @@ -158,10 +179,6 @@ public function test_ms_sites_list_table_invalid_path_search_items() {
}

public function test_ms_sites_list_table_subdomain_domain_search_items() {
if ( ! is_subdomain_install() ) {
$this->markTestSkipped( 'Domain search is not available for subdirectory configurations.' );
}

$_REQUEST['s'] = 'test';

$this->table->prepare_items();
Expand All @@ -182,10 +199,6 @@ public function test_ms_sites_list_table_subdomain_domain_search_items() {
}

public function test_ms_sites_list_table_subdomain_domain_search_items_with_trailing_wildcard() {
if ( ! is_subdomain_install() ) {
$this->markTestSkipped( 'Domain search is not available for subdirectory configurations.' );
}

$_REQUEST['s'] = 'test*';

$this->table->prepare_items();
Expand All @@ -206,10 +219,6 @@ public function test_ms_sites_list_table_subdomain_domain_search_items_with_trai
}

public function test_ms_sites_list_table_subdirectory_path_search_items_with_trailing_wildcard() {
if ( is_subdomain_install() ) {
$this->markTestSkipped( 'Path search is not available for subdomain configurations.' );
}

$_REQUEST['s'] = 'fo*';

$this->table->prepare_items();
Expand All @@ -226,6 +235,7 @@ public function test_ms_sites_list_table_subdirectory_path_search_items_with_tra
self::$site_ids['make.wordpress.org/foo/'],
self::$site_ids['www.w.org/foo/'],
self::$site_ids['www.w.org/foo/bar/'],
self::$site_ids['foo.example.com/'],
);

$this->assertSameSets( $expected, $items );
Expand Down
Loading