From f113c2c1d18baa30c71f2f8368a288729f1f8ee7 Mon Sep 17 00:00:00 2001 From: Tam Date: Fri, 3 Nov 2017 19:55:44 +0000 Subject: [PATCH] No orderBy bug fix Fixed a bug where location searches would error if `orderBy` was not defined --- CHANGELOG.md | 4 ++++ composer.json | 2 +- src/services/MapService.php | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9218db1..f210864 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.0.2 - 2017-11-03 +### Fixed +- Fixed a bug where location searches would error if `orderBy` was not defined + ## 3.0.1 - 2017-11-03 ### Fixed - Fixed maps not rendering diff --git a/composer.json b/composer.json index c149ffa..3262b35 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "ether/simplemap", "description": "A beautifully simple Google Map field type.", - "version": "3.0.1", + "version": "3.0.2", "type": "craft-plugin", "license": "MIT", "minimum-stability": "dev", diff --git a/src/services/MapService.php b/src/services/MapService.php index f93d689..cf1f35b 100644 --- a/src/services/MapService.php +++ b/src/services/MapService.php @@ -202,12 +202,20 @@ public function modifyElementsQuery (ElementQueryInterface $query, $value) ] ); + if (!is_array($query->orderBy)) { + $oldOrderBy = $query->orderBy; + $query->orderBy = []; + } + if (array_key_exists('location', $value)) { $this->_searchLocation($query, $value); } else if (array_key_exists('distance', $query->orderBy)) { $this->_replaceOrderBy($query); } + if (isset($oldOrderBy)) + $query->orderBy = $oldOrderBy; + return; }