Skip to content

Commit

Permalink
Merge pull request silverstripe#10763 from sunnysideup/patch-25
Browse files Browse the repository at this point in the history
MINOR: faster checking if record exists
  • Loading branch information
GuySartorelli authored May 5, 2023
2 parents 0978a43 + 9660652 commit 1c2e1f8
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/Security/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -924,15 +924,8 @@ public function inGroup($group, $strict = false)
}

$groupCandidateObjs = ($strict) ? $this->getManyManyComponents("Groups") : $this->Groups();
if ($groupCandidateObjs) {
foreach ($groupCandidateObjs as $groupCandidateObj) {
if ($groupCandidateObj->ID == $groupCheckObj->ID) {
return true;
}
}
}

return false;
return $groupCandidateObjs->filter(['ID' => $groupCheckObj->ID])->exists();
}

/**
Expand Down

0 comments on commit 1c2e1f8

Please sign in to comment.