Seems to me that using facets with this module is broken. I made a facet, assigned it to search page and nothing is shown. I did place blocks in proper regions but nothing is displayed and when I uncheck "Hide facet when facet source is not rendered" i can get title of block, but when I try to do search there is an error displayed.
Symfony\Component\Routing\Exception\ResourceNotFoundException: No routes found for "/search/solr/my_keyword". in Drupal\Core\Routing\Router->matchRequest() (line 125 of /var/www/drupaldump/web/core/lib/Drupal/Core/Routing/Router.php).
Using Drupal 8.6.13 and facets 8.x-1.3
To test this all I did create a views search and assign facets to it, block appear and function normally.
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | 3046872-30-MR180.diff | 1.06 KB | kriboogh |
| #26 | facets-3046872-26.patch | 953 bytes | rollins |
Issue fork facets-3046872
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3046872-base-path-ajax
changes, plain diff MR !180
- 3046872-base-path-ajax-v2
changes, plain diff MR !242
Comments
Comment #2
swentel commentedI've been bitten a few times here as well. What 'fixed' it for me was making sure the path on the search api page did NOT start with a forward slash. A cache clear after save made sure the page worked fine.
Comment #3
legolasboI've tried to reproduce this in several ways but am unable to do so. Please provide clear steps to reproduce this based on a clean Drupal installation.
Comment #4
harings_rob commentedHi,
We are running into a similar issue.
Our facets (Ajax) are broken when our site is running from a subfolder and we have multiple languages enabled.
Site url example: http://test.test/web/en/search
I did some digging but could not find a direct cause.
Comment #5
olivier.br commentedI have the same issue with drupal installed in a subfolder and ajax enabled.
Stripping the base path from the $path variable in FacetBlockAjaxController.php resolve the issue for me.
I move the issue to facets project.
i use drupal 8.8.4 and latest dev version of facets.
Comment #7
santhosh-kumar-rengasamy commented@swentel
I am facing the same issue, having the website in sub folder. The solution of removing the forward is not working in the views, it adds slash even we save the url without slash.
Any other solution for this.
Comment #8
santhosh-kumar-rengasamy commentedWhen i try using the composer this doesn't getting applied. Throws the below error:
Comment #9
VishnuTRZ commentedThis Patch Works for me. When our drupal is installed under subfolder we facing this issue in factes ajax call. Thanks for the Patch.
Comment #10
olivier.br commentedsame patch but for 8.x-1.6
Comment #11
claudiu.cristeaComment #12
claudiu.cristeaComment #13
mkalkbrennerI wonder if this is safe enough. What if the base path as a string is part of a path alias.
I think that this should be replaced by a regex replace that takes the position into account.
Comment #14
david.muffley commented#10 works for my site with a base path.
Re: #13, I agree. However I'd say rather than altering the received `facet_link` value in the controller, the ajax query shouldn't include the Drupal base path in that value. Use drupalSettings.path.currentPath instead. I took a brief look through the javascript and one use case is easy to change (facets-view-ajax.js Drupal.Ajax.prototype.beforeSend function), but the other is some event flow that I'm not familiar with so I can't judge it.
Comment #15
rakshith.thotada commentedAdded patch for 1.8.x
Comment #16
mihaic commentedHi this patch is not working with latest version of Facets 2.0.6.
Uploading a new version.
Comment #17
rossb89 commentedI've changed the check to use a preg_replace ensuring the base_path() is at the start of the string (a bit safer than just the str_replace).
For version 2.0.6.
Comment #18
phma commented#17 fixes the issue for me also. I agree that ajax_query should not include the base path in the first place. But with #3052574: Facets with AJAX not working in most of situations not yet fixed, it's nice to have a minimal solution which does not interfere.
Comment #19
jamiep commentedI'm not sure if this was caused by something specific to our multisite setup, #17 didn't work for us.
In our case, base_path() is coming through as '/uk/', and $path is an absolute URL including the host and scheme (https://site.example)
As such, $path does not start with /uk/, so the regex doesn't replace anything.
Uploading a new patch to handle as absolute URLs.
Comment #20
joseph.olstadPatch 19 looks like it'll cover more use cases.
Comment #21
bramdriesenPatch #19 also fixed this issue for us for a website living on a subfolder.
Comment #22
rollins commentedComment #25
borisson_Committed, thanks everyone.
Comment #26
rollins commentedpatches from guys resolved individual errors, but they did not resolve all cases
for example #17 patch resolves the bug with Ajax facets, but if the page includes a view text filter, it will show the same error as for facets
#19 patch resolves bug with view text filter, but does not handle with facets
so I merged these patches and created MR for it
This will handle all cases
note:
I was able to create MR only for 2.0.x version, there are no other options for now
so currently this MR can not be applied to check 2.0.6 version
I will attach the patch
Comment #27
joseph.olstadreview for the latest patch (@rollins , please create a new Merge Request for this)
Comment #28
rollins commentedjoseph.olstad it looks @borisson_ merged the wrong MR
That MR does not include one of the cases that I wrote on #26
I created a new MR that includes all fixes, also I replaced str_contains with strpos,
because not all websites support this (str_contains only exists in php8)
Comment #29
nginex commentedThe MR looks good, it handles one more bug
+1
Comment #30
kriboogh commentedAdded the patch for the MR!180 as it stands now to use in composer.
Comment #31
borisson_Hard disagree. Please use str_contains instead. https://github.com/symfony/polyfill-php80 will ensure everyone can use this.
Comment #32
joseph.olstadSafe to say we can rely on php8 + because <= php 7.4 is officially unsupported by current Symfony based Drupals. This module is for D10/D11 not D8.
Therefore, I have no objection to the objection. With that said, I'm ok with strpos. I myself am hooked on strpos but I agree that str_contains is far easier to understand and reads better and it would be great to adopt str_contains.
Currently the biggest issue here is that the pipeline is failing (RED), would appreciate some assistance fixing that.
Comment #35
malcomio commentedWe ran into this problem after switching from a patched version of 2.0.x-dev at commit 3e6c1ea7 to 2.0.9.
It's an odd issue, as it only seems to happen for anonymous users without any cookies from our site, and only on our (acquia) hosting, not on local dev environments.
MR 180 doesn't seem to have any changes any more.
One thing we will try is catching the
ResourceNotFoundExceptionand throwing aNotFoundHttpException- see merge request 242The other patches we have are for these issues:
#3052574: Facets with AJAX not working in most of situations
#3058314: Facets lost when search term changes, only with ajax
Comment #37
malcomio commentedThe issue we are seeing is addressed in #3480277: ResourceNotFoundException on 404 pages .
We had originally connected it to better_exposed_filters - see #3396769: Error when added to 404 pages
Comment #38
david.muffley commentedThe change in MR180 was committed during #3467119: Point support > source at project page in composer.json for whatever reason. So this issue is released in 2.0.9. Not sure what to do with the status so I'll put it into RTBC and hope credit is given eventually I guess.
Comment #39
borisson_if it is already comitted, I can set this to fixed.