Skip to content

Commit

Permalink
Fix exception triggered by non-string values being sent to str_contai…
Browse files Browse the repository at this point in the history
…ns()
  • Loading branch information
sebastian-lenz committed Jul 20, 2023
1 parent da8ba65 commit 43ff41b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/foreignField/ForeignFieldQueryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,19 @@ static protected function enableEagerLoad(ElementQuery $query, ForeignField $fie
* @return bool
*/
static protected function enableJoin(ElementQuery $query, ForeignField $field): bool {
$items = array_merge(
$values = array_merge(
is_array($query->orderBy) ? $query->orderBy : [$query->orderBy],
is_array($query->groupBy) ? $query->groupBy : [$query->groupBy],
[Json::encode($query->where)]
);

foreach ($items as $key => $value) {
if (
str_contains($key, $field->handle) ||
str_contains($value, $field->handle)
) {
$values = array_filter(
array_merge(array_values($values), array_keys($values)),
fn($value) => is_string($value) && !empty($value)
);

foreach ($values as $value) {
if (str_contains($value, $field->handle)) {
return true;
}
}
Expand Down

0 comments on commit 43ff41b

Please sign in to comment.