diff --git src/bp-core/classes/class-bp-user-query.php src/bp-core/classes/class-bp-user-query.php
index 5216fda..2352007 100644
|
|
class BP_User_Query { |
364 | 364 | // 'include' - User ids to include in the results. |
365 | 365 | $include = false !== $include ? wp_parse_id_list( $include ) : array(); |
366 | 366 | $include_ids = $this->get_include_ids( $include ); |
367 | | if ( ! empty( $include_ids ) ) { |
| 367 | |
| 368 | // An array containing nothing but 0 should always fail. |
| 369 | if ( 1 === count( $include_ids ) && 0 == reset( $include_ids ) ) { |
| 370 | $sql['where'][] = $this->no_results['where']; |
| 371 | } elseif ( ! empty( $include_ids ) ) { |
368 | 372 | $include_ids = implode( ',', wp_parse_id_list( $include_ids ) ); |
369 | 373 | $sql['where'][] = "u.{$this->uid_name} IN ({$include_ids})"; |
370 | 374 | } |
diff --git tests/phpunit/testcases/core/class-bp-user-query.php tests/phpunit/testcases/core/class-bp-user-query.php
index 205cb26..1a87f70 100644
|
|
class BP_Tests_BP_User_Query_TestCases extends BP_UnitTestCase { |
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
| 70 | * @ticket BP7248 |
| 71 | */ |
| 72 | public function test_include_array_contaning_only_0_should_result_in_no_results_query() { |
| 73 | $q = new BP_User_Query( array( |
| 74 | 'include' => array( 0 ), |
| 75 | ) ); |
| 76 | |
| 77 | $this->assertContains( '0 = 1', $q->uid_clauses['where'] ); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @ticket BP7248 |
| 82 | */ |
| 83 | public function test_include_array_contaning_0_but_also_real_IDs_should_not_result_in_no_results_query() { |
| 84 | $q = new BP_User_Query( array( |
| 85 | 'include' => array( 0, 1 ), |
| 86 | ) ); |
| 87 | |
| 88 | $this->assertNotContains( '0 = 1', $q->uid_clauses['where'] ); |
| 89 | } |
| 90 | |
| 91 | /** |
70 | 92 | * @group user_ids |
71 | 93 | */ |
72 | 94 | public function test_bp_user_query_user_ids_with_invalid_user_id() { |