Skip to content

Commit

Permalink
No orderBy bug fix
Browse files Browse the repository at this point in the history
Fixed a bug where location searches would error if `orderBy` was not defined
  • Loading branch information
Tam committed Nov 3, 2017
1 parent 491c1ac commit f113c2c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/services/MapService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit f113c2c

Please sign in to comment.