From 47df2d5c61e5a86920051297fd4d74df8b18304f Mon Sep 17 00:00:00 2001 From: iglocska Date: Tue, 1 May 2018 01:28:05 +0200 Subject: [PATCH] fix: Attribute values that are too long for mysql text fields don't generate warnings and just truncate, fixes #3196 added validation error --- app/Model/Attribute.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Model/Attribute.php b/app/Model/Attribute.php index 5117f2fc3..4e60d6e1f 100644 --- a/app/Model/Attribute.php +++ b/app/Model/Attribute.php @@ -420,6 +420,9 @@ class Attribute extends AppModel { 'validComposite' => array( 'rule' => array('validComposite'), 'message' => 'Composite type found but the value not in the composite (value1|value2) format.' + ), + 'maxTextLength' => array( + 'rule' => array('maxTextLength') ) ), 'to_ids' => array( @@ -734,6 +737,13 @@ class Attribute extends AppModel { return true; } + public function maxTextLength($fields) { + if (strlen($fields['value']) > 65535) { + return 'The entered string is too long and would get truncated. Please consider adding the data as an attachment instead'; + } + return true; + } + public function validCategory($fields) { $validCategories = array_keys($this->categoryDefinitions); if (in_array($fields['category'], $validCategories)) return true;