From 093ec7fb135188f5b69dc6275c5608a7b2511176 Mon Sep 17 00:00:00 2001 From: jekkos Date: Mon, 18 May 2026 14:13:20 +0200 Subject: [PATCH] fix: validate attributeId > 0 in saveAttributeLink() (#4508) - Add early validation to reject attributeId <= 0 - Ensure consistent handling of invalid attribute_id in INSERT/UPDATE paths - Prevent foreign key constraint violations from invalid attribute references Fixes #4460 Co-authored-by: Ollama Co-authored-by: objecttothis <17935339+objecttothis@users.noreply.github.com> --- app/Models/Attribute.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Models/Attribute.php b/app/Models/Attribute.php index d48abad2d..33cbdac43 100644 --- a/app/Models/Attribute.php +++ b/app/Models/Attribute.php @@ -601,6 +601,10 @@ class Attribute extends Model */ public function saveAttributeLink(int $itemId, int $definitionId, int $attributeId): bool { + if ($attributeId <= 0) { + return false; + } + $normalizedItemId = empty($itemId) ? null : $itemId; $normalizedAttributeId = empty($attributeId) ? null : $attributeId;