Skip to content

Commit

Permalink
Fixed handling of null queries for PR #321
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebb767 committed Jan 26, 2023
1 parent 490a585 commit 7327939
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,7 @@ public function getAllTags(): array
*/
public function getEntries(Query $query = null): ResourceArray
{
$queryData = $query ? $query->getQueryData() : [];
if (!isset($queryData['locale'])) {
if (null !== $query && null === $query->getLocale()) {
$query->setLocale($this->defaultLocale);
}

Expand All @@ -415,7 +414,7 @@ public function getEntries(Query $query = null): ResourceArray
$entries = $this->request(
'GET',
'/spaces/'.$this->spaceId.'/environments/'.$this->environmentId.'/entries',
['query' => $query->getQueryData()]
['query' => null === $query ? [] : $query->getQueryData()]
);

$this->queryPool->save($query, $entries);
Expand Down
8 changes: 8 additions & 0 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,12 @@ public function setLocale(string $locale = null)

return $this;
}

/**
* Get the locale currently set for this query.
*/
public function getLocale(): ?string
{
return $this->locale;
}
}

0 comments on commit 7327939

Please sign in to comment.