Skip to content

Commit

Permalink
Merge pull request #1220 from creative-commoners/pull/1.8/limit-list
Browse files Browse the repository at this point in the history
ENH Remove duplicate permission check
  • Loading branch information
Maxime Rainville authored Jul 12, 2021
2 parents a287291 + a77bae9 commit 530219b
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions _legacy/GraphQL/FolderTypeCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,26 +208,7 @@ public function resolveChildrenConnection(
});
}

// Filter by permission
// DataQuery::column ignores surrogate sorting fields
// see https://github.com/silverstripe/silverstripe-framework/issues/8926
// the following line is a workaround for `$ids = $list->column('ID');`
$ids = $list->dataQuery()->execute()->column('ID');

$permissionChecker = File::singleton()->getPermissionChecker();
$canViewIDs = array_keys(array_filter($permissionChecker->canViewMultiple(
$ids,
$context['currentUser']
)));
// Filter by visible IDs (or force empty set if none are visible)
// Remove the limit as it no longer applies. We've already filtered down to the exact
// IDs we need.
$canViewList = $list->filter('ID', $canViewIDs ?: 0)
->limit(null);

$result = $childrenConnection->resolveList($list, $args);

return $result;
return $childrenConnection->resolveList($list, $args);
}

/**
Expand Down

0 comments on commit 530219b

Please sign in to comment.