Ticket #8443: 8443.01.patch
File 8443.01.patch, 3.0 KB (added by , 4 years ago) |
---|
-
src/bp-core/classes/class-bp-invitation.php
diff --git src/bp-core/classes/class-bp-invitation.php src/bp-core/classes/class-bp-invitation.php index 6c9fe44a1..8e731290b 100644
class BP_Invitation { 422 422 * invite_sent 423 423 * Only create a where statement if something less than "all" has been 424 424 * specifically requested. 425 */ 425 */ 426 426 if ( ! empty( $args['invite_sent'] ) && 'all' !== $args['invite_sent'] ) { 427 427 if ( $args['invite_sent'] == 'draft' ) { 428 428 $where_conditions['invite_sent'] = "invite_sent = 0"; … … class BP_Invitation { 443 443 // search_terms. 444 444 if ( ! empty( $args['search_terms'] ) ) { 445 445 $search_terms_like = '%' . bp_esc_like( $args['search_terms'] ) . '%'; 446 $where_conditions['search_terms'] = $wpdb->prepare( "( class LIKE %s )", $search_terms_like, $search_terms_like );446 $where_conditions['search_terms'] = $wpdb->prepare( '( class LIKE %s OR invitee_email LIKE %s OR content LIKE %s )', $search_terms_like, $search_terms_like ); 447 447 } 448 448 449 449 // Custom WHERE. -
tests/phpunit/testcases/core/invitations.php
diff --git tests/phpunit/testcases/core/invitations.php tests/phpunit/testcases/core/invitations.php index 149179cd4..0646557a4 100644
include_once BP_TESTS_DIR . 'assets/invitations-extensions.php'; 173 173 174 174 $this->set_current_user( $old_current_user ); 175 175 } 176 176 177 177 public function test_bp_invitations_add_request_vanilla() { 178 178 $old_current_user = get_current_user_id(); 179 179 … … include_once BP_TESTS_DIR . 'assets/invitations-extensions.php'; 287 287 $this->set_current_user( $old_current_user ); 288 288 } 289 289 290 public function test_bp_invitations_get_by_search_terms() { 291 $old_current_user = get_current_user_id(); 292 293 $u1 = $this->factory->user->create(); 294 $u2 = $this->factory->user->create(); 295 $this->set_current_user( $u1 ); 296 297 $invites_class = new BPTest_Invitation_Manager_Extension(); 298 299 // Create an invitation. 300 $i1_args = array( 301 'user_id' => $u2, 302 'inviter_id' => $u1, 303 'item_id' => 1, 304 'content' => 'Sometimes, the mystery is enough.', 305 ); 306 $i1 = $invites_class->add_invitation( $i1_args ); 307 $invites_class->send_invitation_by_id( $i1 ); 308 309 // Create an invitation that uses an email address. 310 $i2_args = array( 311 'invitee_email' => 'findme@buddypress.org', 312 'inviter_id' => $u1, 313 'item_id' => 1, 314 ); 315 $i2 = $invites_class->add_invitation( $i2_args ); 316 $invites_class->send_invitation_by_id( $i2 ); 317 318 $get_invites = array( 319 'search_terms' => 'mystery', 320 'fields' => 'ids', 321 ); 322 $invites = $invites_class->get_invitations( $get_invites ); 323 $this->assertEqualSets( array( $i1 ), $invites ); 324 325 $get_invites = array( 326 'search_terms' => 'findme', 327 'fields' => 'ids', 328 ); 329 $invites = $invites_class->get_invitations( $get_invites ); 330 $this->assertEqualSets( array( $i2 ), $invites ); 331 332 $this->set_current_user( $old_current_user ); 333 } 334 290 335 }