Skip to content

Commit

Permalink
Merge pull request #14395 from craftcms/feature/cms-1262-addressquery…
Browse files Browse the repository at this point in the history
…-querying-by-primaryownerid

Feature/cms 1262 addressquery querying by primaryownerid
  • Loading branch information
brandonkelly authored Feb 15, 2024
2 parents 460889a + 5dc7623 commit 630c5f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- Fixed various issues with Tags fields. ([#14356](https://github.com/craftcms/cms/issues/14356), [#14359](https://github.com/craftcms/cms/pull/14359))
- Fixed a bug where it was possible to include single-instance fields multiple times in a field layout. ([#14352](https://github.com/craftcms/cms/issues/14352))
- Fixed a bug where nested entries could become orphaned when pressing “Save as a new entry”. ([#14378](https://github.com/craftcms/cms/issues/14378))
- Fixed a bug where querying for addresses by `primaryOwnerId` wasn’t working ase expected. ([#14395](https://github.com/craftcms/cms/pull/14395))
- Fixed a bug where read/write splitting was always getting disabled for GraphQL POST requests. ([#14324](https://github.com/craftcms/cms/issues/14324))
- Fixed a bug where GraphQL schema edit pages could include empty category headings.
- Fixed a bug where asset slideouts weren’t showing validation errors on the Filename field. ([#14329](https://github.com/craftcms/cms/issues/14329))
Expand Down
6 changes: 3 additions & 3 deletions src/elements/db/AddressQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -1269,11 +1269,11 @@ protected function beforePrepare(): bool
}

$this->defaultOrderBy = ['elements_owners.sortOrder' => SORT_ASC];
} elseif (isset($this->ownerId)) {
if (!$this->ownerId) {
} elseif (isset($this->primaryOwnerId) || isset($this->ownerId)) {
if (!$this->primaryOwnerId && !$this->ownerId) {
throw new QueryAbortedException();
}
$this->subQuery->andWhere(['addresses.primaryOwnerId' => $this->ownerId]);
$this->subQuery->andWhere(['addresses.primaryOwnerId' => $this->primaryOwnerId ?? $this->ownerId]);
}

if ($this->countryCode) {
Expand Down

0 comments on commit 630c5f7

Please sign in to comment.