Hello,

After some tests with Facets Ajax block feature, i find a bad practice.
The path given in parameter of inbound and outbound processors must to be clean (without query parameters).

The path built with "facet_link" parameter is directly given in paramters of processInboud method in FacetBlockAjaxController::ajaxFacetBlockView() :


  public function ajaxFacetBlockView(Request $request) {

...

    $path = $request->request->get('facet_link');

...

    $processed = $this->pathProcessor->processInbound($path, $new_request);

...

Query parameters are available in the "$new_request" variable and should not be in "$path".

Thanks to clear "$path" variable before "processInbound()" call :

$parsed_path = parse_url($path);
$processed = $this->pathProcessor->processInbound($parsed_path['path'], $new_request);

EDIT: Add patch proposal

Comments

S3b0uN3t created an issue. See original summary.

s3b0un3t’s picture

Issue summary: View changes
StatusFileSize
new809 bytes
karlshea’s picture

Title: Path given to inbound path processor in FacetBlockAjaxController::ajaxFacetBlockView() is not clean » FacetBlockAjaxController::ajaxFacetBlockView() should not be passing full URL to CurrentPathStack
StatusFileSize
new810 bytes

This is breaking facets_summary ResetFacetsProcessor::build(). The $url there built from $facets_summary->getFacetSource()->getPath() ends up getting a full URL instead of just a path, which breaks Url::fromUserInput().

This probably explains a lot of the 500 errors that people are seeing from some Ajax requests.

karlshea’s picture

Status: Active » Needs review
karlshea’s picture

Version: 8.x-1.4 » 8.x-1.x-dev
mglaman’s picture

Priority: Normal » Critical

Bumping to major. It's causing 500 errors.

mglaman’s picture

Status: Needs review » Reviewed & tested by the community

This stopped our page from having 500 errors with Views + AJAX

borisson_’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed, thanks!

Status: Fixed » Closed (fixed)

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

berdir’s picture

This was closed, but I don't see the commit anywhere. I just updated to 2.0.1 and the patch still applies. Looks like it wasn't pushed?

mkalkbrenner’s picture

Status: Closed (fixed) » Needs review
berdir’s picture

StatusFileSize
new782 bytes

Looks like it conflicts with #3253542: FacetBlockAjaxController breaks the RequestStack in Drupal 9.3.0, I didn't review if the fix is even still necessary or if those other changes resolved somehow, just a git apply -3 powered reroll.

  • mkalkbrenner committed 8a9574d on 2.0.x authored by Berdir
    Issue #3110730 by S3b0uN3t, KarlShea, Berdir, mglaman, borisson_,...
mkalkbrenner’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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