From fddd2d1220a85262d41cdee41b2537f3a3301130 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 9 Oct 2015 14:56:01 -0500 Subject: [PATCH] forms: Avoid dropping the CDATA table MySql 5.6 and MariaDB 10 will return affected_rows == 0 if updating a row to its current values. Therefore, if an object is "edited", but none of the CDATA is modified, then the CDATA table might be dropped and rebuilt. --- include/class.dynamic_forms.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 49b7e94e3..2b2586886 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -327,7 +327,7 @@ class DynamicForm extends VerySimpleModel { $cdata['object_id'], db_input($answer->getEntry()->get('object_id'))) .' ON DUPLICATE KEY UPDATE '.$fields; - if (!db_query($sql) || !db_affected_rows()) + if (!db_query($sql)) return self::dropDynamicDataView($cdata['table']); } @@ -523,7 +523,7 @@ class TicketForm extends DynamicForm { $sql = 'INSERT INTO `'.TABLE_PREFIX.'ticket__cdata` SET '.$fields .', `ticket_id`='.db_input($answer->getEntry()->get('object_id')) .' ON DUPLICATE KEY UPDATE '.$fields; - if (!db_query($sql) || !db_affected_rows()) + if (!db_query($sql)) return self::dropDynamicDataView(); } } -- GitLab