开发者

Drupal - Search showing preg_match error

I have a custom search going on in one of the website I am building in Drupal. Search works perfectly fine when the "Rebuild theme registry on every page." checkbox is selected on the Theme Configure page. However, when I uncheck it (for production), the search no longer works, the same page just reloads again on hitting the search button. Upon looking at the Recent Log Entries I found the error: preg_match() expects parameter 2 to be string, array given in /var/www/devel_sites/SITENAME/docroot/modules/search/search.module on line 671.

开发者_如何学运维Anybody got any ideas why my search would be depending upon the theme registry and how to fix this? I have a custom module for search and part of the functionality is in template.php.

Any tips are appreciated, thanks.


Without posting code (since the code is custom,) I don't think anyone can answer your question satisfactorily. However, if you don't mind modifying module code, simply do a is_array conditional before line 671 and if it is, implode the terms (or inspect it and get rid of any garbage.) Pass that string on to line 671.


I was (finally) able to resolve the issue and I am posting the resolution below in case someone else faces the same.

I started by moving all the functional logic from template.php to my custom module (I should have done it anyways and it seemed like it might be an issue) but it didn't solve it. I had to dig in my custom module code and that's where I found what the problem was. I was using the following to get the entered keywords:

$form_state['values']['processed_keys']

It turns out, when Rebuild Theme registry option is turned off, the above array value is overwritten by the theme registry and is being replaced by an empty array, hence causing the error in line 671 of the search module which, is expecting a string as the second argument, and not an array. Replacing the above with the below solved it for me:

$form['basic']['inline']['processed_keys']['#post']['keys']

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜