I have a exposed form with a search filter.

When I submit the form I get the following error:

Fatal error: Call to undefined function search_parse_query() in D:\xampp\htdocs\hundekauf_drupal7_local\sites\all\modules\views\modules\search\views_handler_filter_search.inc on line 57 Call Stack: 0.0006 68008 1. {main}() D:\xampp\htdocs\hundekauf_drupal7_local\index.php:0 0.2768 24438600 2. menu_execute_active_handler() D:\xampp\htdocs\hundekauf_drupal7_local\index.php:22 0.2770 24439664 3. call_user_func_array() D:\xampp\htdocs\hundekauf_drupal7_local\includes\menu.inc:480 0.2770 24439664 4. views_page() D:\xampp\htdocs\hundekauf_drupal7_local\includes\menu.inc:0 0.2786 24441872 5. view->execute_display() D:\xampp\htdocs\hundekauf_drupal7_local\sites\all\modules\views\views.module:319 0.3161 24629064 6. views_plugin_display_page->execute() D:\xampp\htdocs\hundekauf_drupal7_local\sites\all\modules\views\includes\view.inc:917 0.3161 24629600 7. view->build() D:\xampp\htdocs\hundekauf_drupal7_local\sites\all\modules\views\plugins\views_plugin_display_page.inc:174 0.3183 24633032 8. views_plugin_exposed_form->render_exposed_form() D:\xampp\htdocs\hundekauf_drupal7_local\sites\all\modules\views\includes\view.inc:655 0.3184 24634000 9. drupal_build_form() D:\xampp\htdocs\hundekauf_drupal7_local\sites\all\modules\views\plugins\views_plugin_exposed_form.inc:126 0.3326 25144952 10. drupal_process_form() D:\xampp\htdocs\hundekauf_drupal7_local\includes\form.inc:345 0.3363 25175960 11. drupal_validate_form() D:\xampp\htdocs\hundekauf_drupal7_local\includes\form.inc:753 0.3365 25177984 12. _form_validate() D:\xampp\htdocs\hundekauf_drupal7_local\includes\form.inc:1018 0.3384 25183912 13. form_execute_handlers() D:\xampp\htdocs\hundekauf_drupal7_local\includes\form.inc:1246 0.3384 25184616 14. views_exposed_form_validate() D:\xampp\htdocs\hundekauf_drupal7_local\includes\form.inc:1305 0.3385 25185080 15. views_handler_filter_search->exposed_validate() D:\xampp\htdocs\hundekauf_drupal7_local\sites\all\modules\views\views.module:1094 

Comments

klaus66’s picture

search_parse_query() is no longer in drupal 7.

I see the class SearchQuery in drupal 7 has this functionallity.

Therefore I think the search filter is not ready yet for drupal 7.

dawehner’s picture

You still have the issue assigned to yourself ;)

klaus66’s picture

Assigned: klaus66 » Unassigned

Thanks.

But how can I change this.

I can edit my comment but not the issue itself.

Can you help me.

dawehner’s picture

That's not as easy to solve as you think. Currently you can comment out this line but

SearchQuery uses form_set_error('keys') which will fail on exposed filters for some cases
=> we have to extend this class?

Alternatve we copy the function from d6 and uses it here.

klaus66’s picture

Yes I think so too.

But I hope you find a solution for this problem, because the search filter is in my eyes a very important filter.

dawehner’s picture

You know there are no many bugs around it's hard to fix every of them at the same time :)
For the most people it's freetime in the issue queue

klaus66’s picture

Yes i understand that there is many work to do and that I must wait.

I must also say that the most things I need at the moment work well except only the
search filter and the click-sorting fields.

oeduardosegura’s picture

Any news?

dawehner’s picture

This issue would be marked as fixed if there would be any news.

dawehner’s picture

StatusFileSize
new9.1 KB

Just some updates.

Now query has to be converted.

bojanz’s picture

Status: Active » Needs work

Setting appropriate status.

iamjon’s picture

Status: Needs work » Needs review

i think this needs review no?

dawehner’s picture

No it doesn't work at all yet.

iamjon’s picture

Status: Needs review » Needs work

my bad resetting the status

mfb’s picture

subscribe

vaartio’s picture

subscribe

duellj’s picture

subscribing

duellj’s picture

StatusFileSize
new9.84 KB

Here's a patch that expands on the patch from #10. I was able to get basic search working with exposed search filters (basically single/multiple search terms). Type searching does not work and neither does OR and Negative operators. There's still a lot to be done; I had to comment out a lot of the code to get it to run and the code is riddled with todo's.

I actually ran into a couple of very odd problems:

      $this->query->add_where($this->options['group'], "$search_index.type = '%s'", $base_table);

This conditional gets rewritten somewhere to: search_index.types (notice the "s" at the end). Bizzare.

      $this->query->add_having($this->options['group'], 'COUNT(*)', $this->matches, '>=');

This having clause get's rewritten to: COUNT >= :db_placeholder. The "(*)" is stripped off of the clause.

Hopefully this will be a start towards getting search filters in views working.

dawehner’s picture

I general i think it's bad that views has a big part of the search.module in it, just to support it.

There is a alternative approach to this.

* Create a object of searchQuery and execute it's helper functions.
* Get the results back by extending searchQuery and use some getter's.

This would allow a much smaller code change than currently.

robash’s picture

Subscribing

ngmaloney’s picture

@dereine I'm currently looking into the feasibility of rolling a patch based on your comment #19. Could this be achieved by replacing the call to search_parse_query() with an instance of SearchQuery and the parseSearchExpression() function? I'm not able to locate any other modules that use SearchQuery object to uses as reference.

dawehner’s picture

That's the problem when working on views. There are often no other modules fighting with this kind of problems :(

Already worked many hours on this problems without any success.

duellj’s picture

The price to pay to be on the forefront of technology :).

dereine, thank you for work on this! Can you post up what you've got so far? (This is where the git issue sandboxes would come in very handy)

dawehner’s picture

As i said i managed to do nothing, at least nothing which can't be achieved in some seconds.
See #19

dawehner’s picture

StatusFileSize
new2.54 KB

Found something from my backup.

Never said that this is something useful

duellj’s picture

Thanks dereine! I'll see what I can do with this patch (@ngmaloney if you want to try too, be my guest).

ngmaloney’s picture

Thanks @dereine and @duellj. I'll post any progress I'm able to make. I think the #25 patch provides some good next steps to look into. The searchQuery() is so heavily abstracted I wasn't sure how to create a useful object instance that views could use.

jonaswouters’s picture

subscribing

aschiwi’s picture

Applied patch from #25, new error message is

Fatal error: Can't use method return value in write context in /path/to/drupal/sites/all/modules/views/modules/search/views_handler_filter_search.inc on line 75

This message shows up after hitting submit on an exposed form for all filters (which work without this patch), even if search is left empty.

aschiwi’s picture

I have some budget to get this fixed, is anyone interested? How much would we need to raise?

dawehner’s picture

This will perhaps be fixed during the dev days in bruessel because

a) there are people which want to hack
b) there are people which understand search.module/dbtng (berdir)

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new9.65 KB

What was needed for this patch

* A full package of cookies
* no fear against this issue.

So here is a patch. It works for me on the preview and in the interface fine.
Both with simple ("searchword") and complicated queries("searchword -butnot).

Just a single quote why there are things which complicates the whole thing.

  public function publicParseSearchExpression() {
    return $this->parseSearchExpression();
  }
aschiwi’s picture

How cool is that! :) This works for me for simple searchwords, but not for the "searchword -butnot". The error for the latter is:

Fatal error: Cannot access protected property DatabaseCondition::$conditions in /path/to/drupal/sites/all/modules/views/modules/search/views_handler_filter_search.inc on line 136
dawehner’s picture

StatusFileSize
new9.93 KB

Okay hacked core to see the variables better :(

aschiwi’s picture

Awesome, now it works as intended!

aschiwi’s picture

Status: Needs review » Reviewed & tested by the community

Let's get it in then :)

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the testing.

Commited to the 7.x branch.

mfb’s picture

Status: Fixed » Needs work

Thanks for getting this in.

One problem I found, there is a fatal error for complex search queries, which you can see if you give it a query that mixes AND (or just multiple words, as the AND is implied) with OR: Recoverable fatal error: Method DatabaseCondition::__toString() must return a string value in views_handler_filter_search->query() (line 141 of /views/modules/search/views_handler_filter_search.inc).

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new2.52 KB

There are places where dbtng really stands out and makes things easy.

Here is a new version.

jrs69’s picture

Sorry, probably a simple question here... first time running a patch..... what directory should i place these patches and after I run the patch command on the command line, which file should we be patching?

ty

dawehner’s picture

See http://drupal.org/patch/apply

The directory is the views module..

mfb’s picture

The patch at #39 seems to fix complex queries for me, thanks.

One other thing though... what about the search argument handler, views_handler_argument_search.inc? That will need to make use of viewsSearchQuery class as well.

dawehner’s picture

Status: Needs review » Fixed

@mfb
Thanks for testing the patch.
Commited to 7.x branch.

Would it be okay to create a new issue for this? Would be cool.
This is not that hard to fix, because we already figured out this problem here.

mfb’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.