Skip to content

Commit

Permalink
adjust hasAlt condition
Browse files Browse the repository at this point in the history
  • Loading branch information
i-just committed Sep 20, 2024
1 parent 8e469fd commit 0ae3856
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/elements/db/AssetQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -994,8 +994,28 @@ protected function afterPrepare(): bool
if ($this->hasAlt !== null) {
$hasAltCondition = [
'or',
['assets.alt' => null],
['assets_sites.alt' => null],
['not', ['assets_sites.alt' => '']],
[
'and',
['assets_sites.alt' => null],
['not', ['assets.alt' => '']],
['not', ['assets.alt' => null]],
],
];

$withoutAltCondition = [
'or',
['assets_sites.alt' => ''],
[
'and',
['assets_sites.alt' => null],
[
'or',
['assets.alt' => ''],
['assets.alt' => null],
],

],
];

$this->subQuery
Expand All @@ -1004,7 +1024,7 @@ protected function afterPrepare(): bool
'[[assets_sites.assetId]] = [[assets.id]]',
'[[assets_sites.siteId]] = [[elements_sites.siteId]]',
])
->andWhere($this->hasAlt ? ['not', $hasAltCondition] : $hasAltCondition);
->andWhere($this->hasAlt ? $hasAltCondition : $withoutAltCondition);
}

return parent::afterPrepare();
Expand Down

0 comments on commit 0ae3856

Please sign in to comment.