Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#7 | 2840272-7--views_query_always_create_condition_group.patch | 1.45 KB | drunken monkey |
| |||
#7 | 2840272-7--views_plugins_check_for_aborted_query.patch | 2.61 KB | drunken monkey |
|
Comments
Comment #2
nielsvoo CreditAttribution: nielsvoo commentedComment #3
drunken monkeyDo you maybe have caching enabled for the view? Try with caching set to "None".
Comment #4
nielsvoo CreditAttribution: nielsvoo commentedThanks for the tip but its already off.
Other suggestions?
Niels
Comment #5
drunken monkeyNot 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?
Comment #6
azovsky CreditAttribution: azovsky commentedI 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.Comment #7
drunken monkeyI 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 returnNULL
, 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.
Comment #8
azovsky CreditAttribution: azovsky commentedThank 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.
Comment #9
drunken monkeyCommitted.