FIX Don't assume DataObject::canView always returns bool (#306)

Because there is no return value typehinting in DataObject::canView, the value returned from that method can be of any type. We must cast to boolean before returning the value to avoid possible errors with non-boolean return types.
This commit is contained in:
GuySartorelli 2022-01-27 11:23:19 +13:00 committed by GitHub
parent 8ac7964220
commit 2c0e2df02d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -151,12 +151,12 @@ class SearchableService
// Anonymous member canView() for indexing
if (!$this->classSkipsCanViewCheck($objClass)) {
$value = Member::actAs(null, function () use ($obj) {
return $obj->canView();
return (bool) $obj->canView();
});
}
} else {
// Current member canView() check for retrieving search results
$value = $obj->canView();
$value = (bool) $obj->canView();
}
}
$this->extend('updateIsSearchable', $obj, $indexing, $value);