Skip to content

Commit e83a3b7

Browse files
committed
Fix some legacy tests
1 parent 50592a5 commit e83a3b7

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/Database/Queries/Concerns/QueriesNestedElements.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ function (JoinClause $join) {
116116
$allowOwnerRevisions = $elementQuery->allowOwnerRevisions ?? ($elementQuery->id || $elementQuery->primaryOwnerId || $elementQuery->ownerId);
117117

118118
if (! $allowOwnerDrafts || ! $allowOwnerRevisions) {
119-
$this->subQuery->join(
119+
$elementQuery->subQuery->join(
120120
new Alias(Table::ELEMENTS, 'owners'),
121121
fn (JoinClause $join) => $join->when(
122122
$elementQuery->ownerId,
123123
fn (JoinClause $join) => $join->on('owners.id', '=', 'elements_owners.ownerId'),
124-
fn (JoinClause $join) => $join->on('owners.id', '=', $this->getPrimaryOwnerIdColumn()),
124+
fn (JoinClause $join) => $join->on('owners.id', '=', $elementQuery->getPrimaryOwnerIdColumn()),
125125
)
126126
);
127127

@@ -134,7 +134,7 @@ function (JoinClause $join) {
134134
}
135135
}
136136

137-
$this->defaultOrderBy = ['elements_owners.sortOrder' => SORT_ASC];
137+
$elementQuery->defaultOrderBy = ['elements_owners.sortOrder' => SORT_ASC];
138138
});
139139
}
140140

@@ -381,19 +381,19 @@ protected function cacheTags(): array
381381
$tags = [];
382382

383383
if ($this->fieldId) {
384-
foreach ($this->fieldId as $fieldId) {
384+
foreach (Arr::wrap($this->fieldId) as $fieldId) {
385385
$tags[] = "field:$fieldId";
386386
}
387387
}
388388

389389
if ($this->primaryOwnerId) {
390-
foreach ($this->primaryOwnerId as $ownerId) {
390+
foreach (Arr::wrap($this->primaryOwnerId) as $ownerId) {
391391
$tags[] = "element::$ownerId";
392392
}
393393
}
394394

395395
if ($this->ownerId) {
396-
foreach ($this->ownerId as $ownerId) {
396+
foreach (Arr::wrap($this->ownerId) as $ownerId) {
397397
$tags[] = "element::$ownerId";
398398
}
399399
}

yii2-adapter/legacy/elements/NestedElementManager.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use craft\events\DuplicateNestedElementsEvent;
2121
use craft\helpers\Cp;
2222
use craft\helpers\ElementHelper;
23+
use CraftCms\Cms\Database\Queries\ElementQuery;
2324
use CraftCms\Cms\Database\Table;
2425
use CraftCms\Cms\Element\Drafts;
2526
use CraftCms\Cms\Element\Enums\PropagationMethod;
@@ -174,12 +175,12 @@ public function getIsTranslatable(?ElementInterface $owner = null): bool
174175
return $this->propagationMethod !== PropagationMethod::All;
175176
}
176177

177-
private function nestedElementQuery(ElementInterface $owner): ElementQueryInterface
178+
private function nestedElementQuery(ElementInterface $owner): ElementQueryInterface|ElementQuery
178179
{
179180
return call_user_func($this->queryFactory, $owner);
180181
}
181182

182-
private function getValue(ElementInterface $owner, bool $fetchAll = false): ElementQueryInterface|ElementCollection
183+
private function getValue(ElementInterface $owner, bool $fetchAll = false): ElementQueryInterface|ElementQuery|ElementCollection
183184
{
184185
if (isset($this->valueGetter)) {
185186
return call_user_func($this->valueGetter, $owner, $fetchAll);
@@ -211,7 +212,7 @@ private function getValue(ElementInterface $owner, bool $fetchAll = false): Elem
211212
return $query;
212213
}
213214

214-
private function setValue(ElementInterface $owner, ElementQueryInterface|ElementCollection $value): void
215+
private function setValue(ElementInterface $owner, ElementQueryInterface|ElementQuery|ElementCollection $value): void
215216
{
216217
if ($this->valueSetter === false) {
217218
return;

0 commit comments

Comments
 (0)