diff --git a/src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php b/src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php index 4077aa4f..9cd613ec 100644 --- a/src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php +++ b/src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Solr\Query\CriterionVisitor; +use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Core\FieldType\Image\Type; use Ibexa\Core\Search\Common\FieldNameResolver; @@ -31,10 +32,12 @@ abstract protected function getSearchFieldName(): string; /** * @return array + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ protected function getSearchFieldNames(Criterion $criterion): array { - return array_keys( + $searchFieldNames = array_keys( $this->fieldNameResolver->getFieldTypes( $criterion, $criterion->target, @@ -42,5 +45,14 @@ protected function getSearchFieldNames(Criterion $criterion): array $this->getSearchFieldName() ) ); + + if (empty($searchFieldNames)) { + throw new InvalidArgumentException( + '$criterion->target', + "No searchable Fields found for the provided Criterion target '{$criterion->target}'." + ); + } + + return $searchFieldNames; } }