[wp-hackers] DB_COLLATE is not used in searches
    Bertilo Wennergren 
    bertilow at gmail.com
       
    Wed Mar 26 07:53:50 GMT 2008
    
    
  
Testing WP-2.1RC1 I found that the collation set in "wp-config.php" 
(DB_COLLATE) is not being used in searches. I think it should.
This can easily be fixed. In "wp-includes/query.php" the following part 
can be changed as indicated here:
// If a search pattern is specified, load the posts that match
if ( !empty($q['s']) ) {
   // [...]
   foreach((array)$q['search_terms'] as $term) {
     $term = addslashes_gpc($term);
     // The following like has been added
     if ($wpdb->collate) $collatesql = ' COLLATE ' . $wpdb->collate;
     // The following line has been changed
     // $collatesql was inserted in two places
     $search .= "{$searchand}(($wpdb->posts.post_title LIKE 
'{$n}{$term}{$n}'$collatesql) OR ($wpdb->posts.post_content LIKE 
'{$n}{$term}{$n}'$collatesql))";
     $searchand = ' AND ';
   }
   // [...]
}
There is probably a more general way to fix this, but the above
simple solution should also work.
-- 
Bertilo Wennergren <http://bertilow.com>
    
    
More information about the wp-hackers
mailing list