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.
Saving a search does not work. Saved search URLs contain no query parameters. They simply link to the View page.
Steps to reproduce:
- Execute a search using a View page.
- Using the "Save Search" block, save a search.
- View saved searches in user profile. Searches link to the View page without any query parameters.
More information:
Path to View page:
/plan-search
Path after executing a search on View page:
/plan-search?f[]=field_product%253Afield_hp_bedrooms:1
- Drupal core version: 7.54
- Using search_api_solr module version: 7.x-1.9
- There are no log messages.
Let me know if I can provide more useful information. This bug breaks the modules purpose completely.
Comment | File | Size | Author |
---|---|---|---|
#14 | 2862680-14--fix-url-query.patch | 6.14 KB | Nikolay Shapovalov |
#4 | 2862680-3--block_cache_none.patch | 599 bytes | drunken monkey |
Comments
Comment #2
maskedjellybeanComment #3
drunken monkeyAre you maybe using AJAX views, or some other means of just loading part of the page? This looks like the "Save search" block would be created in a previous page request, where the view doesn't have any filters.
Another possibility would be block caching going wrong there, though it seems unlikely unless you have a (buggy) custom caching solution in place. But please see if the attached patch fixes your problem. (Or do you maybe use something like Panels for displaying the "Save search" block, instead of Drupal's regular block system?)
Comment #4
drunken monkey(Forgot to attach the patch.)
Comment #5
danthornePatch didn't work for me. Issue I have is when using ajax_facets as a widget.
Comment #6
danthorneI'm guessing that it is because the ajax_facets query is f[]=field_filter:38 rather then f[]=field_filter=38
Comment #7
danthorneActually I don't think thats the issue. It seems that f[0] at the start is replaced with f%255B0%255D which saved search doesn't like.
Comment #8
danthorneSorry, after more testing I think it is because ajax_facets url looks like f[], if I append f[0], f[1] ..etc the saved search works.
I'll see if theres any way to change this with ajax_facets.
Comment #9
rjacobs CreditAttribution: rjacobs at Center for Research Libraries commentedIf this is specific to core >= 7.55 I suppose it may be related to the known issue about URL generating functions:
https://www.drupal.org/project/drupal/releases/7.55
Search API saved searches links generally depend on the query string to properly pass filter args, and, for some setups at least, these are encoded as an array in the URL. So I think that core issue may apply.
Comment #10
Nikolay ShapovalovI have same issue. I think problem is at SearchApiSavedSearchesViewsHandlerFieldName::render_text().
I think the reason that in some facet name colon ":" is used.
Working link I have from facet on search page
f%5B0%5D=user%253Alast_login%3Alast_3_months
After url decode it converts to
f[0]=user%3Alast_login:last_3_months
Broken link from saved search page:
f%5B0%5D=user%3Alast_login%3Alast_3_months
After url decode it converts to
f[0]=user:last_login:last_3_months
I think we need to change how url is generated.
Comment #11
Nikolay ShapovalovComment #12
Nikolay ShapovalovComment #13
Nikolay ShapovalovComment #14
Nikolay ShapovalovI provide patch. I change way params added to query. And overwrite views_handler_field::render_as_link function, this is simple patch apply https://www.drupal.org/files/issues/2909709-7.patch.
Comment #15
Nikolay ShapovalovComment #17
drunken monkeyThanks a lot for the patch!
As this seems to be quite a different issue than the one originally reported, I think you should have rather created a new issue instead of resurrecting this one, but as your patch seems to work fine (and there doesn’t seem to be a chance that either Views or Drupal will fix this yet for D7), I’ll just commit this.
Thanks again!