Skip to content

Commit c00d9c6

Browse files
committed
Merge branch 'craft-4' of https://github.com/verbb/wishlist into craft-5
# Conflicts: # src/elements/db/ItemQuery.php
2 parents 4a5d8e2 + c2205b9 commit c00d9c6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/elements/db/ItemQuery.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ protected function beforePrepare(): bool
106106
$this->joinElementTable('wishlist_items');
107107

108108
$this->subQuery->innerJoin('{{%wishlist_lists}} wishlist_lists', '[[wishlist_items.listId]] = [[wishlist_lists.id]]');
109+
$this->subQuery->innerJoin('{{%elements}} lists_elements', '[[wishlist_items.listId]] = [[lists_elements.id]]');
109110

110111
// And join the element table for the linked element, in order to fetch non-deleted linked elements
111112
$this->query->leftJoin('{{%elements}} element_item', '[[wishlist_items.elementId]] = [[element_item.id]]');
@@ -173,6 +174,14 @@ protected function beforePrepare(): bool
173174
$this->query->andWhere(['element_item.dateDeleted' => null]);
174175
}
175176

177+
// Ensure that we respect the trashed param, in case the list has been deleted. We don't update the item's deleted
178+
// status (but we probably should!). TODO: querying only trashed items won't work for example...
179+
if ($this->trashed === false) {
180+
$this->subQuery->andWhere(['lists_elements.dateDeleted' => null]);
181+
} else if ($this->trashed === true) {
182+
$this->subQuery->andWhere(['not', ['lists_elements.dateDeleted' => null]]);
183+
}
184+
176185
return parent::beforePrepare();
177186
}
178187
}

0 commit comments

Comments
 (0)