Problem/Motivation
If we use facet summary, with the Reset Link option enabled, then we've got a fatal error when used with views embeded (embed or block views display mode).
InvalidArgumentException: The user-entered string '' must begin with a '/', '?', or '#'. in Drupal\Core\Url::fromUserInput() (line 214 of core/lib/Drupal/Core/Url.php).
Drupal\facets_summary\Plugin\facets_summary\processor\ResetFacetsProcessor->build(Object, Array, Array) (Line: 137)
Drupal\facets_summary\FacetsSummaryManager\DefaultFacetsSummaryManager->build(Object) (Line: 91)
Drupal\facets_summary\Plugin\Block\FacetsSummaryBlock->build() (Line: 171)
Drupal\block\BlockViewBuilder::preRender(Array)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 772)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 363)
this is because this piece of code in the ResetFacetsProcessor plugin
$url = Url::fromUserInput($facets_summary->getFacetSource()->getPath());
The path of a view embedded is NULL.
Proposed resolution
Check if the path is NULL or NOT, and if NULL fallback to the current route.
Comments
Comment #2
flocondetoileComment #3
flocondetoileLooks like the root cause of that is in the changes between facets 1.8 and 2.0.
In 1.8, we have in the facet_source Plugin SearchApiDisplay
in 2.0 version
we have
And view embedded are not "rendered in the current request".
Comment #4
mkalkbrennerWhat about moving the logic into getPath() to have it centralized?
Comment #5
flocondetoileYes. It could be better, but would like to have some feedback from maintainers about this change introduced in the getPath() method
Comment #6
mkalkbrennerTake a look at that issue committed 2 months ago.
Comment #7
flocondetoileThanks (and sorry, I didn't see you were one of the maintainers :-)).
Attached a patch which move the fix into the SearchApiDisplay->getPath() method.
Comment #8
flocondetoileComment #9
marcoka commentedI have a Layoutbuilder page with a search api views block and some facet blocks.
When added a summary it would always crash the page. With that patch an actual path is returned and not null.
I applied it and here is a debug shot of the variables:
http://www.root.artwaves.de/sharex/09-02-22--17-03-03.jpg