CRM-15276 fixes - DB Syntax Error on saving new mailing component with checked is_default
authormonishdeb <monish.deb@webaccessglobal.com>
Thu, 11 Sep 2014 14:39:51 +0000 (20:09 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Thu, 11 Sep 2014 14:39:51 +0000 (20:09 +0530)
https://issues.civicrm.org/jira/browse/CRM-15276

CRM/Mailing/BAO/Component.php

index 2c23cdf5d5362b3ffeba507b2f52e1767c6583a7..55dd8b35fb3d99492322ec1b1f7d8c056b2ffff6 100644 (file)
@@ -98,7 +98,7 @@ class CRM_Mailing_BAO_Component extends CRM_Mailing_DAO_Component {
       $component->body_text = CRM_Utils_String::htmlToText(CRM_Utils_Array::value('body_html', $params));
     }
 
-    if ($component->is_default) {
+    if ($component->is_default && !empty($id)) {
       CRM_Core_DAO::executeQuery("UPDATE civicrm_mailing_component SET is_default = 0 WHERE component_type ='{$component->component_type}' AND id <> $id");
     }