After hours and hours of trying to fix my issue with the new Drupal 8 Search API i give up, it seems there is a bug when AJAX is enabled in the view settings. I am building a site were search is embedded in a Bootstap jQuery Modal and therefore AJAX must be enabled, otherwise the search is not loaded within the model.

To be sure I've tested it on a search page not loaded in the model, the fist time the search showed some results (just like in de modal version) but after a couple of strings it stops working. The moment i turn of AJAX it works flawless.

Thanks for your advice.

Niels

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nielsvoo created an issue. See original summary.

nielsvoo’s picture

Issue summary: View changes
drunken monkey’s picture

Do you maybe have caching enabled for the view? Try with caching set to "None".

nielsvoo’s picture

Thanks for the tip but its already off.
Other suggestions?

Niels

drunken monkey’s picture

Not really, sorry. I can't reproduce the problem, either – for me, search views work fine with AJAX turned on, too.
Do you maybe have some other modules enabled that could influence this? Try turning those off one by one to see if it starts working at some point.
Does it maybe work just for anyonmous or registered users?

azovsky’s picture

I have an issue in a views where set the AJAX option as " Use AJAX: Yes".

Drupal 8.6.15; Search API 8.x-1.x-dev updated 21 Apr 2019 at 14:38 UTC; search_api_solr 8.x-2.7.

Used a contextual filter by date field.

The site is down with a message:
Error: Call to a member function addCondition() on null in Drupal\search_api\Plugin\views\argument\SearchApiDate->query() (line 98 ...

Looks like when enabled AJAX then $this->query->createConditionGroup() in web\modules\contrib\search_api\src\Plugin\views\argument\SearchApiDate.php not working. New conditions not created.

drunken monkey’s picture

I don’t think that’s the root cause of your problem.
The problem rather seems to be that the Views query plugin encountered some issue earlier that caused it to be aborted. In that case, createConditionGroup() will return NULL, causing this problem. (Seems we already encountered and fixed this for the fulltext search filter, back in #2939085: Views, search fails when user searches for space (patch attached), but missed it for some other spots.)

So, that fatal error in your case only masks the real problem. (Apparently, some other problem regarding your view and AJAX. I, for one, can’t reproduce this. Nothing to do with the date contextual filter, in any case.) Nonetheless, it should of course not happen, we should properly guard against that. For that, I have two patches to propose, both of which would take care of the problem in different ways. (Personally, I’d prefer views_query_always_create_condition_group, but I’m open to other opinions there.)

Once you apply either patch and try again, you should see the real error that keeps your view from working with AJAX.

azovsky’s picture

Thank you @drunken-monkey! I will try patches!

So far I have refused to use any contextual filters in my View. Instead, I programmatically read/add required parameters.

drunken monkey’s picture

Status: Needs review » Fixed

Committed.

  • drunken monkey committed 9b89c32 on 8.x-1.x
    Issue #2840272 by drunken monkey: Fixed fatal error in certain Views...

Status: Fixed » Closed (fixed)

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