Problem/Motivation

[warning] foreach() argument must be of type array|object, null given SearchApiExcludeEntityByField.php:86

Steps to reproduce

Having an error when doing search indexing (drush sapi-i)

Comments

ambot112 created an issue. See original summary.

ambot112’s picture

Created a patch to remove the indexName on array level.

ambot112’s picture

Title: Error in indexing » Error in indexing using SearchApiExcludeEntityByField
smustgrave’s picture

Would probably need exact steps. Just putting an empty check is usually masking a different issue

smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)
knowak’s picture

I think I ran into a similar issue when I testing where I found that the content with the field and value I added was not being excluded.

After some debugging I found the fields in the config are not nested under the indexName. I have a single database backend/server and a single index .

Expecting:
config
> indexName
> fields

Reality:
config
> fields

public function alterIndexedItems(array &$items): void {
    $config = $this->getConfiguration();
    $indexName = $this->index->getOriginalId();
    $configuredField = $config[$indexName]['fields'];
. . .

The patch fixed the issue for me.

  • smustgrave committed 423b6416 on 3.0.x
    fix: #3513038 Error in indexing using SearchApiExcludeEntityByField
    
    By...
smustgrave’s picture

Status: Postponed (maintainer needs more info) » Fixed

Small change so I'll include.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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