Ticket #7442: bp-search-use-joins2.patch
File bp-search-use-joins2.patch, 2.0 KB (added by , 8 years ago) |
---|
-
src/bp-core/classes/class-bp-user-query.php
412 412 $search_terms_nospace = '%' . $search_terms . '%'; 413 413 $search_terms_space = '%' . $search_terms . '%'; 414 414 } 415 416 $sql[' where']['search']= $wpdb->prepare(417 " u.{$this->uid_name} IN ( SELECT ID FROM {$wpdb->users} WHERE ( user_login LIKE %s OR user_login LIKE %s OR user_nicename LIKE %s OR user_nicename LIKE %s ))",415 416 $sql['select'] .= $wpdb->prepare( 417 " LEFT JOIN {$wpdb->users} r ON r.ID = u.{$this->uid_name} AND ( r.user_login LIKE %s OR r.user_login LIKE %s OR r.user_nicename LIKE %s OR r.user_nicename LIKE %s )", 418 418 $search_terms_nospace, 419 419 $search_terms_space, 420 420 $search_terms_nospace, 421 421 $search_terms_space 422 422 ); 423 424 $sql['where']['search'] = "r.ID IS NOT NULL"; 423 425 } 424 426 425 427 // Only use $member_type__in if $member_type is not set. -
src/bp-xprofile/bp-xprofile-functions.php
781 781 782 782 // Combine the core search (against wp_users) into a single OR clause 783 783 // with the xprofile_data search. 784 $s earch_xprofile= $wpdb->prepare(785 " u.{$query->uid_name} IN ( SELECT user_id FROM {$bp->profile->table_name_data} WHERE value LIKE %s ORvalue LIKE %s )",784 $sql['select'] .= $wpdb->prepare( 785 " LEFT JOIN {$bp->profile->table_name_data} p ON p.user_id = u.{$query->uid_name} AND ( p.value LIKE %s OR p.value LIKE %s )", 786 786 $search_terms_nospace, 787 787 $search_terms_space 788 788 ); 789 789 790 790 $search_core = $sql['where']['search']; 791 $search_combined = " ( {$search_xprofile}OR {$search_core} )";792 $sql['where']['search'] = $search_combined;791 $search_combined = " ( p.id IS NOT NULL OR {$search_core} )"; 792 $sql['where']['search'] = $search_combined; 793 793 794 794 return $sql; 795 795 }