Merge pull request #10763 from sunnysideup/patch-25

MINOR: faster checking if record exists
This commit is contained in:
Guy Sartorelli 2023-05-05 13:12:06 +12:00 committed by GitHub
commit 1c2e1f86a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -924,15 +924,8 @@ class Member extends DataObject
}
$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();
}
/**