Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Fix single unpublished entries in listing column #9917

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/Fieldtypes/Entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ protected function collect($value)
return new \Statamic\Entries\EntryCollection($value);
}

public function augment($values)
private function queryBuilder($values)
{
$site = Site::current()->handle();
if (($parent = $this->field()->parent()) && ($parent instanceof Localization || $parent instanceof LocalizedTerm)) {
Expand All @@ -335,8 +335,13 @@ public function augment($values)
->filter()
->all();

$query = (new StatusQueryBuilder(new OrderedQueryBuilder(Entry::query(), $ids)))
return (new StatusQueryBuilder(new OrderedQueryBuilder(Entry::query(), $ids)))
->whereIn('id', $ids);
}

public function augment($values)
{
$query = $this->queryBuilder($values);

return $this->config('max_items') === 1 ? $query->first() : $query;
}
Expand Down Expand Up @@ -409,13 +414,7 @@ public function getColumns()

protected function getItemsForPreProcessIndex($values): SupportCollection
{
if (! $augmented = $this->augment($values)) {
return collect();
}

return $this->config('max_items') === 1
? collect([$augmented])
: $augmented->whereAnyStatus()->get();
return $this->queryBuilder($values)->whereAnyStatus()->get();
}

public function filter()
Expand Down
Loading