Skip to content

Commit

Permalink
pkp#8288 Fix missing assoc_type check; properly enclose OR clause
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Aug 4, 2023
1 parent 52d13c6 commit b802e3e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions classes/announcement/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use PKP\core\Core;
use PKP\core\interfaces\CollectorInterface;
use PKP\plugins\Hook;
use APP\core\Application;

/**
* @template T of Announcement
Expand Down Expand Up @@ -133,16 +134,17 @@ public function getQueryBuilder(): Builder

if (isset($this->contextIds)) {
$qb->whereIn('a.assoc_id', $this->contextIds);
$qb->where('a.assoc_type', Application::get()->getContextAssocType());
}

if (isset($this->typeIds)) {
$qb->whereIn('a.type_id', $this->typeIds);
}

if (isset($this->isActive)) {
$qb->when($this->isActive, fn($qb) => $qb->where(function($qb) {
$qb->where('date_expire', '<=', $this->isActive)
->orWhereNull('date_expire');
}
->orWhereNull('date_expire');
}));

if ($this->searchPhrase !== null) {
$words = explode(' ', $this->searchPhrase);
Expand Down

0 comments on commit b802e3e

Please sign in to comment.