Problem/Motivation

When I'm trying to display facet block for the block display of the view (has no path parameter) I can see a notice:
Deprecated function: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\facets\Plugin\facets\facet_source\SearchApiDisplay->buildFacet() (line 396 of modules/contrib/facets/src/Plugin/facets/facet_source/SearchApiDisplay.php).

Steps to reproduce

Create a view, add block to this view, create facet for this block, display the facet block.

Proposed resolution

It's required to check if $view->getPath() function returns not null result.

Remaining tasks

No tasks

User interface changes

No changes

API changes

No changes

Data model changes

No changes

Comments

geophysicist created an issue. See original summary.

geophysicist’s picture

StatusFileSize
new891 bytes

Here is a patch

idebr’s picture

Version: 2.0.1 » 2.0.x-dev
Status: Active » Needs review
phthlaap’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new871.83 KB

I tested this issue, it happen in PHP 8.1. After apply the patch it is ok.

Step to re-produce:

- Step 1: Install module Facets, Search API
- Step 2: Add search index for content
- Step 3: Add the field Tag into search index
- Step 4: Add new search index view with display block, enable ajax for the view
- Step 5: Add Facets for the view
- Step 6: Go to block layout, add the view into home
- Step 7: Add Facets block into home

Issue before apply the patch:
error

mkalkbrenner’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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