If a user uses a broken link to a site with facets without the facet id, the Query string URL processor gives a PHP warning:

Example broken link: http://example.com/nl/search?search_api_fulltext=in%20vitro%20techniek&i...

You see the id is missing from the facet parameter, but this should not cause a warning.

The warning:

Warning: Invalid argument supplied for foreach() in Drupal\facets\Plugin\facets\url_processor\QueryString->initializeActiveFilters() (line 180 of modules/contrib/facets/src/Plugin/facets/url_processor/QueryString.php).

Comments

jummonk created an issue. See original summary.

borisson_’s picture

I agree, we should be more defensive here, nice catch @jummonk!

borisson_’s picture

Status: Active » Needs review
StatusFileSize
new1.05 KB
new1.76 KB

Something like this should work, I added a test as well.

The last submitted patch, 3: broken_facet_link-2871475-3--testonly.patch, failed testing.

borisson_’s picture

StatusFileSize
new1.76 KB

Patch no longer applied, reroll attached.

  • borisson_ committed e74b874 on 8.x-1.x
    Issue #2871475 by borisson_: Broken facet link causes PHP warning in...
borisson_’s picture

Status: Needs review » Fixed

Fixed.

Status: Fixed » Closed (fixed)

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

jummonk’s picture

Patch doesn't seem to solve it for me.

Error: [] operator not supported for strings in Drupal\facets\Plugin\facets\url_processor\QueryString->buildUrls() (line 106 of modules/contrib/facets/src/Plugin/facets/url_processor/QueryString.php).

On broken link example.be/nl/search?search_api_fulltext=in%20vitro%20techniek&items_per_page=10&f