Ticket #7442: bp-search-optimize.patch
File bp-search-optimize.patch, 2.3 KB (added by , 7 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 $matched_user_ids = $wpdb->get_col($wpdb->prepare( 417 "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 )", 418 418 $search_terms_nospace, 419 419 $search_terms_space, 420 420 $search_terms_nospace, 421 421 $search_terms_space 422 ); 422 )); 423 424 $match_in_clause = empty($matched_user_ids) ? 'NULL' : implode(',', $matched_user_ids); 425 426 $sql['where']['search'] = "u.{$this->uid_name} IN ({$match_in_clause})"; 423 427 } 424 428 425 429 // 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 $ search_xprofile =$wpdb->prepare(785 " u.{$query->uid_name} IN ( SELECT user_id FROM {$bp->profile->table_name_data} WHERE value LIKE %s OR value LIKE %s )",784 $matched_user_ids = $wpdb->get_col($wpdb->prepare( 785 "SELECT user_id FROM {$bp->profile->table_name_data} WHERE value LIKE %s OR value LIKE %s", 786 786 $search_terms_nospace, 787 787 $search_terms_space 788 ) ;788 )); 789 789 790 $search_core = $sql['where']['search']; 791 $search_combined = "( {$search_xprofile} OR {$search_core} )"; 792 $sql['where']['search'] = $search_combined; 790 if (!empty($matched_user_ids)) { 791 $search_core = $sql['where']['search']; 792 $search_combined = " ( u.{$query->uid_name} IN (" . implode(',', $matched_user_ids) . ") OR {$search_core} )"; 793 $sql['where']['search'] = $search_combined; 794 } 793 795 794 796 return $sql; 795 797 }