_trip_search_excerpt_replace uses array_walk incorrectly
| Project: | SQL Search (Trip Search) |
| Version: | 4.6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | mindless |
| Status: | closed |
Jump to:
array_walk passes in a reference to the callback, so you should be modifying the value in place instead of returning the value. Also, since you're going to be using the quoted value in a regex that uses / as the delimiter, use that as the delimiter argument to preg_quote().
This fixes the problem that searching for "foo/car" gives a PHP warning: "warning: preg_replace(): Unknown modifier 'c' in trip_searh.module on one 654"
Line numbers may be off, we've got a patched version of the module, but line 654 for me is:
$text = preg_replace('/('. implode('|', $keys) .')/i', '\0', $text);
===================================================================
--- trip_search.module (revision 433)
+++ trip_search.module (working copy)
@@ -658,8 +658,8 @@
/**
* Helper function for array_walk in trip_search_excerpt.
*/
-function _trip_search_excerpt_replace($text) {
- return preg_quote($text);
+function _trip_search_excerpt_replace(&$text) {
+ $text = preg_quote($text, "/");
}

#1
patch applied to DRUPAL-4-6 and DRUPAL-4-7 branches
#2