Hi, I tried to use the submodule taxonomy, but when I select a taxonomy to show up as filter in a custom search block, I get the following error message :

warning: Invalid argument supplied for foreach() in /var/www/admin/data/www/website.com/includes/form.inc on line 1211.

I get one for each taxonomy filter I try to add.
The filters are still displayed, the search works but not the filters (The results includes everything whatever the terms I may have selected before submitting)

Can the problem come from an incompatibility with the Content Taxonomy or the Content Profile modules I use ?
Any help truly appreciated !

Comments

jdanthinne’s picture

Have you tried with Content Taxonomy disabled, just to see if the problem comes from this module (or mine)?

fourmi4x’s picture

Hi, Many thanks for handling that !

I forgot to mention that I use Apache Solr, which replaces the default search (so my custom blocks lead to apache solr search).
So Solr uses the core taxonomy instead of the content taxonomy fields, but I don't know what Custom Search uses ?

I also have a newbie question : if I disable content taxonomy, will it break my rules/views/links or other modules using it (it is kind of the base of my website...) ?

jdanthinne’s picture

Custom Search also use the core taxonomy system.

If you disable the module, I think nothing will be lost, but "hidden" until you re-enable it. To be sure, I think it would be safier to do the test on a local copy of your website.

Additionaly, in the content taxanomy fields you've defined, have you checked the option to save the values in the core taxonomy system?

fourmi4x’s picture

Yes, I have checked the option, in fact I think Solr doesn't work yet with Content Taxonomy, so one has to check the option in order for Solr to work with the taxonomies defined in Content Taxonomy.

I don't have a local copy of my website yet, but this issue is a good reason to start creating one, so I will come back to you when all this is done. Thanks again!

scuba_fly’s picture

I installed the custom search module and got exactly the same problem.

I looked it up in the code form.inc line 1211:
foreach ($form['#default_value'] as $key) {

so i guess $form or $form['#default_value'] needs to be set in the custom search module where hook_form is called
this is set on line 123 of custom_search.module: $form[$form_id]['#default_value'] = variable_get('custom_search_' . $delta . 'text', '');

but i can't find where custom_search_text is set ( $delta === '' )

greetings,

scuba_fly

jdanthinne’s picture

Still not getting this error… Can you give me a simple way to reproduce it?

custom_search_text is set on the admin page (custom_search.admin.inc, line 35):

$form['search_box']['custom_search_text'] = array(
    '#type'           => 'textfield',
    '#title'          => t('Search box default text'),
    '#default_value'  => variable_get('custom_search_text', ''),
    '#description'    => t('This will change the default text inside the search form. Leave blank for no text. This field is blank by default.'),
  );

Do you have a test url?
Can you tell me the list of enabled modules?
Which settings do you use for custom_search?

scuba_fly’s picture

looking at the code custom_search_text can't be the problem i guess.

I've set up a test on http://bank-en-verzekeringen-vacatures.nl/drupal6/

I'm using the following modules:

Administration
Administration menu 6.x-1.6

CCK
Content 6.x-2.8
Content Copy 6.x-2.8
Content Taxonomy 6.x-1.0-rc2
Content Taxonomy Autocomplete 6.x-1.0-rc2
Content Taxonomy Options 6.x-1.0-rc2
Content Taxonomy Tree 6.x-1.0-rc2
Fieldgroup 6.x-2.8
Link 6.x-2.9
Node Reference 6.x-2.8
Number 6.x-2.8
Option Widgets 6.x-2.8
Text 6.x-2.8

Chaos tool suite
Chaos tools 6.x-1.8

Core - optional
Aggregator 6.19
Color 6.19
Comment 6.19
Contact 6.19
Content translation 6.19
Database logging 6.19
Help 6.19
Locale 6.19
Menu 6.19
Profile 6.19
Search 6.19
Taxonomy 6.19
Update status 6.19

Custom Search
Custom Search 6.x-1.6
Custom Search Blocks 6.x-1.6
Custom Search Taxonomy 6.x-1.6

Database
Schema 6.x-1.7

Devel
Coder 6.x-2.0-beta1
Devel 6.x-1.22

Feeds
Feeds 6.x-1.0-beta10
Feeds Admin UI 6.x-1.0-beta10
Feeds XPath Parser 6.x-1.9

custom build(ing)
A module for parsing XML feeds and mapping them to content type (basically it is creating nodes on xml input )

The settings I'm using in custom_search are the default and I've put al the elements in 'Block' region.
Also I'm using the 'Checkboxes' Selector type for all the custom search fields/terms.

If you have any more questions, of want me to try anything let me know.

greetings!

jdanthinne’s picture

Status: Active » Needs review
StatusFileSize
new1.24 KB

I think I've found the problem...
Try this patch…

scuba_fly’s picture

I'm a bit of a newbee to drupal. so i don't know how to apply the patch ( working on windows machines ).
anyway i changed the line manually
'#default_value' => ((variable_get('custom_search' . $delta . '_voc' . $voc->vid . '_selector', 'select') == 'checkboxes') ? array('c-all') : 'c-all'), '
to:
'#default_value' => ($selector_type == 'checkboxes') ? array('c-all') : 'c-all',

because that's what this patch does?

the error message is gone and i think search is still working.
I'm building custom nodes so they might not be searchable by tax terms. When i click search i go to the search page and my selected terms are selected under 'advanced search'. So I think this fixed it!
many thanks!

can you confirm that fourmi4x?

greetings!

fourmi4x’s picture

Hi, unfortunately I didn't have any success with the patch : I don't get the error message anymore, but each time I make a custom search, everything seems ok until I get the URL "http://mywebsite/search/apahesolr_search/?filters=type:tool" and then it crashes my browser (forced to restart computer!).
In the log, I only see " filters=type:tool (Search).", no error.

In fact, my normal solr search, that I do with a ustom search block that replaces the default search, doesn't work anymore, I get the two following errors :

    * recoverable fatal error: Object of class stdClass could not be converted to string in website.com/sites/all/modules/custom_search/modules/custom_search_blocks/custom_search_blocks.module on line 126.
    * recoverable fatal error: Object of class stdClass could not be converted to string in website.com/sites/all/modules/custom_search/custom_search.module on line 292.

I also try to use the taxonomy filtering on a second custom block I created and placed on a page (There is nothing on the page except that). When I want to edit that page, I only get the first of the error messages (about line 126), + an other one, so :

    * recoverable fatal error: Object of class stdClass could not be converted to string in website.com/sites/all/modules/custom_search/modules/custom_search_blocks/custom_search_blocks.module on line 126.
    * warning: htmlspecialchars() expects parameter 1 to be string, object given in website.com/includes/bootstrap.inc on line 857.

The line 126 being : $form['custom_search_blocks_form_' . $delta] = array(
And the line 292 : $delta = (isset($form_state['values']['delta'])) ? 'blocks_' . $form_state['values']['delta'] . '_' : '' ;

So I guess there is something wrong with the conversion/format of the delta... ?

I'm quite a newbee to drupal to... but if you want me to test anything, I would be happy to do so.

jdanthinne’s picture

@scuba_fly : yes, that's what the patch does. And It's already committed to the DEV version.

@fourmi4x : wow, I've never seen a drupal site crashing a browser! Have you tried with another theme (Garland)? Do you have a test url for me te see the code? Or can you send the generated code of a page (click on my name for a private message)?

fourmi4x’s picture

Version: 6.x-1.6 » 6.x-1.5

Hi, thanks again for supporting this issue. I have classified my researches :

--------- Browser Problem
As you mention that drupal crashing a browser was weird, I tried my website from another laptop (at my workplace), and surprise : the error messages are not displayed ! So there is obviously a problem with my computer/browsers (because I tried several of them, and they all crash), but that's not related to drupal...

--------- Javascript incompatibility with Node Display
That allowed me to find out what the source of the crash is : I get a popup saying :
Warning : Script does not respond"
and then :
Script : http://www.website.com/sites/all/modules/nd_contrib/nd_search/nd_search.js?m:53

So it must come from a javascript incompatibility with the module Node Display that I have installed...
The nd_search.js essentialy does one thing : highlight keywords. So I unchecked the highlighting option in the Node Display Search settings, and the script doesn't bug anymore :D

--------- Advanced Search missing
But the taxonomy filter was not working... and I couldn't see any "Advanced search" section. So I disabled the Node Display Search module.
But it still doesn't work and doesn't display the advanced search.
I then realized that Apache Solr has not the advanced search implemented yet! (As seen here : http://drupal.org/node/899096 , which also propose a solution to implement it but it looks very complex to code)

When I don't make Apache Solr the default search, I get one more tab above my search results : I have "Content" appears next to the default "Search" tab.
"Content" contains the advanced filter, but my custom search still redirects to the "Search" tab which is the Solr search (which is what I want)... but without the advanced search (However, there is a "Retain current filters" checkbox under the search box.)

--------- Questions
So is the Custom Search advanced search (that we can configure into "Results Page) normally displayed even with Solr search ?
If not, that may be why taxonomy filters are not taken into account ?
Do you still want the code of the page (which page?) ?

@scuba_fly : Do you use Apache Solr as default search ?

NB 1: Garland gives the same results
NB 2 : I just realized I only have the 6.x-1.5 version of custom search... can it be the problem?

I hope that was not too confusing... !

jdanthinne’s picture

Status: Needs review » Active

So…
First : when you've got bugs like this, you should always test with the latest DEV version, just to see if your problems have already been fixed (or not). So I encourage you to do so, and see if some of the problems are gone.

-- Browser problem
I was sure about that :-)

-- Javascript incompatibility with Node Display
I'll have a look at that module, to see what I can do to remove this incomptability

-- Advanced Search missing
The advanced search is provided by the default search module, so this is normal. Solr has to implement it.
So, unfortunately, you have to choose… Solr search but without advanced search, or defautl search with it.

Tell me wich solution you take and if the taxonomy filter works or not, that way.

scuba_fly’s picture

@fourmi4x : Nope I'm using the default search without Solr

try using the latest dev version as jdanthunne suggested.

Being new here should i change the version to 6.x-1.6 ( because that was the original issue and is committed to the DEV version ) ?

jdanthinne’s picture

Version: 6.x-1.5 » 6.x-1.x-dev
fourmi4x’s picture

I updated to the dev version as you advised (sorry I didn't think of it sooner).

Regarding the choice I have to make, if I sum up :

Option 1 : Solr search : filter terms one by one, after the search, via facets.
=> I tested it, it still doesn't work, probably simply because of the advanced search missing in Solr.

Option 2 : Custom Search with Taxonomy : multiple filters, before search. No Solr search at all (module disabled, otherwise Custom Search redirects automatically to solr search (results tab), even when I disable "Make Apache Solr Search the default" => is there any way to change that ?).
=> it works, in the same way scuba_fly mentioned :)

What I'm looking for and think would be awesome, would be :
Option 3 : Multiple filters, before search (run with solr), with ability to re-filter via facets after search

---------
Regarding the Advanced Search not being in Solr search :
I looked for this and found two posts providing some code :
Complex solution for Solr version 2.x, apparently only to filter by content type : http://drupal.org/node/326375#comment-3321886
Simpler solution for Solr version 1.x, idem : http://drupal.org/node/452874
I thus posted a request for what I'm looking for here : http://drupal.org/node/998936, which does not really involve Custom Search anymore...which means sacrifying all its great features :(

But if this is not possible with Solr, would it then be possible to connect, in some way, the Custom Search Taxonomy filters to the Solr taxonomy facets, so that the terms chosen via Custom search Taxonomy automatically select the same terms in Solr facets, to obtain Option 3 ? (So "bypassing/without using" advanced search)

This could open the door for a potentially much more sophisticated configuration of drupal search, through the combination of Solr and Custom Search module ? (multiple customizable search blocks using fully customized searches !!)

Are Custom search paths a thing to look into ?

jdanthinne’s picture

StatusFileSize
new565 bytes

Hi,
here's a first patch for Option 2 (if Solr is not set as default search, don't use it!), so you can enable Solr module.

jdanthinne’s picture

@fourmi4x:
I've just checked about this "Javascript incompatibility with Node Display", but on my side, I've installed the latest version of this module, checked the option to highlight the terms, but everything's fine, no error message…

jdanthinne’s picture

Status: Active » Needs review
StatusFileSize
new1.04 KB

Forget the patch at #17 and please use this one instead…
This patch will:
- not use Solr if not set as defaut search
- handle correctly taxonomy terms selectors to post them to Solr search (and will be selected in facet filters)

If think this patch will solve all your problems (I hope).

fourmi4x’s picture

The patch works perfectly, it is exactly what I needed, thank you very much !!

This is just really awesome, being able to select multiple filters, then launch search, and then refine via facets !

In the meantime, I continued to search and found an alternative here : http://groups.drupal.org/node/31696
=> I discovered that in the 6.x-2.x-dev version of Solr Integration, there is an option to display all facets on an empty search (cf. http://drupal.org/node/457826)

But I prefer your solution / to use custom search, because users can select multiple filters at once, and then launch the search, instead of re-searching each time a facet is clicked (much more server-intensive...)

However, I still have the problem that users have to enter something in the searchbox to launch the search => Would it be possible to authorize empty searches ? (I don't dare to ask, you have already done a lot !)

Regarding the "javascript incompatibility" with node display, re-tested it with my new version of solr/custom search, and I don't have the error anymore... So that seems solved :)

jdanthinne’s picture

De rien, très cher! (I've seen you're from France, and I'm from Belgium :-) )

I'll have a look at this other module for the empty search.
Should be easy (I added the javascript validation because core search doesn't like empty searches, so it's just a matter of checking if you're using Solr or not…).

fourmi4x’s picture

J'ai vraiment l'impression que ce site est truffé de francophones... ! :-)
Tell me if I can help in any way !

jdanthinne’s picture

StatusFileSize
new3.23 KB

Here's a patch for the empty search.
It's working nice with 6.x-2.x-dev version of Solr.
Please clear cache after applying it (because javascript code has been changed).

fourmi4x’s picture

The patch works perfectly :-)

Thank you very very much, I finally have my amazing search experience !!

I'm closing the issue because we eventually went quite far off the original topic... pour le meilleur :)

fourmi4x’s picture

Status: Needs review » Closed (fixed)
inteldesk’s picture

I set the search form as an exposed block, and it also heads to 404. I disabled the search in themes config prior to activating the custom_search module

jdanthinne’s picture

As an exposed block? How do you do that? Only Views has exposed blocks I think.