Skip to content

Commit

Permalink
fix: Fixed an issue where an exception would be thrown if orderBy w…
Browse files Browse the repository at this point in the history
…as `null` ([#49](#49))
  • Loading branch information
khalwat committed Apr 28, 2024
1 parent 0081cc4 commit 840babc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/services/Similar.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function find(array $data): array|ElementInterface
$query = $this->getElementQuery($elementClass, $criteria);

// Stash any orderBy directives from the $query for our anonymous function
$this->preOrder = $query->orderBy;
$this->preOrder = $query->orderBy ?? [];
$this->limit = $query->limit;
// Extract the $tagIds from the $context
if (is_array($context)) {
Expand Down Expand Up @@ -144,7 +144,7 @@ public function find(array $data): array|ElementInterface
$query = $this->getElementQuery($elementClass, $criteria);

// Make sure we fetch the elements that are similar only
$query->on(ElementQuery::EVENT_AFTER_PREPARE, function (CancelableEvent $event) use ($queryConditions): void {
$query->on(ElementQuery::EVENT_AFTER_PREPARE, function(CancelableEvent $event) use ($queryConditions): void {
/** @var ElementQuery $query */
$query = $event->sender;
$first = true;
Expand Down

0 comments on commit 840babc

Please sign in to comment.