Skip to content

Commit

Permalink
FIX: Check if filtered list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Cambis committed Aug 12, 2024
1 parent e94f976 commit 81a1cd8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Admin/AdvancedWorkflowAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ public function setFieldFormatting(&$config)
/**
* Return content-object data depending on which gridfeld is calling for it
*
* @return DataList<WorkflowInstance>
* @return DataList<WorkflowInstance>|null
* @throws InvalidArgumentException
*/
public function getFieldDependentData(Member $user, string $fieldName): DataList
public function getFieldDependentData(Member $user, string $fieldName): ?DataList
{
$list = null;

Expand Down Expand Up @@ -249,6 +249,10 @@ public function getFieldDependentData(Member $user, string $fieldName): DataList
return true;
});

if ($list->count() === 0) {
return null;
}

// Return a DataList with the filtered ids
return WorkflowInstance::get()->filter([
'ID' => $list->column('ID'),
Expand Down Expand Up @@ -385,6 +389,10 @@ private function getPendingItems(GridFieldConfig $config): ?GridField
{
$pending = $this->getFieldDependentData(Security::getCurrentUser(), 'PendingObjects');

if (!$pending instanceof DataList) {
return null;
}

if ($pending->count() === 0) {
return null;
}
Expand Down Expand Up @@ -420,6 +428,10 @@ private function getSubmittedItems(GridFieldConfig $config): ?GridField
{
$submitted = $this->getFieldDependentData(Security::getCurrentUser(), 'SubmittedObjects');

if (!$submitted instanceof DataList) {
return null;
}

if ($submitted->count() === 0) {
return null;
}
Expand Down

0 comments on commit 81a1cd8

Please sign in to comment.