From 2c0e2df02d3c970606e384b3fdccec42e06fd1f9 Mon Sep 17 00:00:00 2001 From: GuySartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Thu, 27 Jan 2022 11:23:19 +1300 Subject: [PATCH] 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. --- src/Search/Services/SearchableService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Search/Services/SearchableService.php b/src/Search/Services/SearchableService.php index a621a75..421d06f 100644 --- a/src/Search/Services/SearchableService.php +++ b/src/Search/Services/SearchableService.php @@ -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);