From 1cc92fc9c200c7c8c9942ea83dbfe6bd13c96567 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Tue, 24 Sep 2013 15:40:18 +0200 Subject: [PATCH] [-] CORE : Could not add too long tags --- classes/Tag.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/classes/Tag.php b/classes/Tag.php index d8fd20c0d..17b0faba4 100644 --- a/classes/Tag.php +++ b/classes/Tag.php @@ -100,22 +100,24 @@ class TagCore extends ObjectModel $tag_list = array_filter(array_unique(array_map('trim', preg_split('#\\'.$separator.'#', $tag_list, null, PREG_SPLIT_NO_EMPTY)))); $list = array(); - foreach ($tag_list as $tag) - { - if (!Validate::isGenericName($tag)) - return false; - $tag_obj = new Tag(null, trim($tag), (int)$id_lang); - - /* Tag does not exist in database */ - if (!Validate::isLoadedObject($tag_obj)) + if (is_array($tag_list)) + foreach ($tag_list as $tag) { - $tag_obj->name = trim($tag); - $tag_obj->id_lang = (int)$id_lang; - $tag_obj->add(); + if (!Validate::isGenericName($tag)) + return false; + $tag = trim(substr($tag, 0, self::$definition['fields']['name']['size'])); + $tag_obj = new Tag(null, $tag), (int)$id_lang); + + /* Tag does not exist in database */ + if (!Validate::isLoadedObject($tag_obj)) + { + $tag_obj->name = $tag; + $tag_obj->id_lang = (int)$id_lang; + $tag_obj->add(); + } + if (!in_array($tag_obj->id, $list)) + $list[] = $tag_obj->id; } - if (!in_array($tag_obj->id, $list)) - $list[] = $tag_obj->id; - } $data = ''; foreach ($list as $tag) $data .= '('.(int)$tag.','.(int)$id_product.'),';