From ae69c87433c202459b168d1795828d668229c711 Mon Sep 17 00:00:00 2001 From: Newt Date: Mon, 1 Dec 2025 22:50:12 +0000 Subject: [PATCH] Fix hasUnlockedLimits to use non-transactional check Updated hasUnlockedLimits function to include user parameter and modified the logic to check if the user has unlocked limits for the given object. Also prevents accidental transactions that could otherwise be triggered --- app/Helpers/Helpers.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Helpers/Helpers.php b/app/Helpers/Helpers.php index 5a24d1b815..40be9cb59b 100644 --- a/app/Helpers/Helpers.php +++ b/app/Helpers/Helpers.php @@ -497,11 +497,17 @@ function hasLimits($object) { * Checks if a user has a limit unlocked. * * @param mixed $object + * @param mixed $user */ -function hasUnlockedLimits($object) { - $service = new App\Services\LimitManager; +function hasUnlockedLimits($user, $object) { + if (!hasLimits($object)) { + return true; + } - return $service->checkLimits($object); + return App\Models\Limit\UserUnlockedLimit::where('user_id', $user->id) + ->where('object_model', get_class($object)) + ->where('object_id', $object->id) + ->exists(); } /**