Problem/Motivation

Facet summary with reset link enabled throws a fatal error on ajax calls, causing summary not being updated. This is the error thrown on server side:

InvalidArgumentException: The user-entered string 'http://absolute-url.com/my-path?f[]=facet-name:value' must begin with a '/', '?', or '#'. in Drupal\Core\Url::fromUserInput() (line 213 of /path/to/drupal/root/core/lib/Drupal/Core/Url.php).

Facet summary reset link processor is assumming we should link to the facet source url, but you could use a view block to display your results inside a node (for example). Not sure if this is related, but in such situation the url obtained is the absolute one, causing the fatal error.

Steps to reproduce

  • Create a search api view with a block display and ajax enabled.
  • Place the view block anywhere.
  • Place some facet blocks and the facet summary on the same page.
  • Filter the view by the facets.
  • The summary won't update and you will find in the logs the error described above.

Proposed resolution

Do not try to point to the facet source url, but to the current path.

Remaining tasks

Review patch

User interface changes

none.

API changes

Data model changes

Comments

akalam created an issue. See original summary.

akalam’s picture

akalam’s picture

Status: Active » Needs review
tbenice’s picture

The patch isn't working for me. With it the facets dont appear until after a page refresh (with ajax on, and the page filtered). Same after reset.

kiseleva.t’s picture

StatusFileSize
new1.27 KB
new1.1 KB

I faced the same issue and reworked the patch.

analiam319@gmail.com’s picture

StatusFileSize
new964 bytes
new679 bytes
new964 bytes

After updating to Drupal Core 9.3.3 and updating to the latest 2.0.x facets release, #5 stopped working for us. With #5 installed, the following error message was reported:

InvalidArgumentException: The URI '' is invalid. You must use a valid URI scheme. in Drupal\Core\Url::fromUri() (line 291 of /app/web/core/lib/Drupal/Core/Url.php).

Re-worked the patch to use "getPathInfo" on the current main request instead of attempting to grab the facet source path. Patches available for both the 2.0.x and 8.x-1.x branches.

analiam319@gmail.com’s picture

StatusFileSize
new1 KB
new885 bytes

Apologies for the previous patch. I didn't notice that the reset link ended up pointing to /views/ajax instead of the actual page path.

Status: Needs review » Needs work

The last submitted patch, 7: facets-2.x-3169104-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

analiam319@gmail.com’s picture

StatusFileSize
new885 bytes
new1.14 KB

Resolving automated tests. Very sorry about the subsequent messages!

nitebreed’s picture

Status: Needs work » Reviewed & tested by the community

This is exactly what I needed, works fine!

loopy1492’s picture

Since upgrading from Facets 1.6 to 2.x, we are having this issue with ANY link, not just the reset link.

We have a view embedded on a page with facets embedded using the blocks interface in a sidebar. The view filters just fine when you're on the page, but if you try to take that link with its querystring and paste it into a browser's address bar, we get the error.

InvalidArgumentException: The user-entered string '' must begin with a '/', '?', or '#'. in Drupal\Core\Url::fromUserInput() (line 214 of /mnt/www/html/oursite/docroot/core/lib/Drupal/Core/Url.php).

The (sanitized) url:

http://oursite.com/catalog?f%5B0%5D=competencies%3APersonal%20and%20Cust...

loopy1492’s picture

We downgraded and pinned to 1.8 until this is fixed. I have created a new issue for this.

mkalkbrenner’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

mkalkbrenner’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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