From 4350facb111da5dfbd5de5e1fd25f5c192c5f10d Mon Sep 17 00:00:00 2001 From: Tam Date: Mon, 16 Sep 2024 11:18:07 +0100 Subject: [PATCH] Fixed location filter affecting unrelated queries Fixes #405 --- CHANGELOG.md | 4 ++++ src/fields/MapField.php | 3 +++ src/services/MapService.php | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8375f70..d36080a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.0.3 - 2024-09-16 +### Fixed +- Fixed location filter affecting unrelated queries (Fixes #405) + ## 5.0.2 - 2024-09-10 ### Fixed - Fixes location search (Fixes #394, #393, #392) diff --git a/src/fields/MapField.php b/src/fields/MapField.php index f6587e2..7d6c53b 100644 --- a/src/fields/MapField.php +++ b/src/fields/MapField.php @@ -436,6 +436,9 @@ public function afterPrepareElementQuery (CancelableEvent $event): void self::$searchParams['value'], self::$searchParams['field'], ); + + // Clear search params to prevent it being applied to unrelated queries. + self::$searchParams = null; } // Helpers diff --git a/src/services/MapService.php b/src/services/MapService.php index ca9f3fc..813020f 100644 --- a/src/services/MapService.php +++ b/src/services/MapService.php @@ -193,7 +193,7 @@ public function modifyElementsQuery (ElementQueryInterface $query, mixed $value, '[[' . $alias . '.fieldId]] = ' . $field->id, ]; - $query->subQuery->join('JOIN', $table . ' ' . $alias, $on); + $query->subQuery->join('LEFT JOIN', $table . ' ' . $alias, $on); if ($value === ':empty:') {