Details
Description
When trying to send a mailing without headers or footers I a foreign key restraint failure:
(`membership-crm/civicrm_mailing`, CONSTRAINT `civicrm_mailing_ibfk_2` FOREIGN KEY (`header_id`) REFERENCES `civicrm_mailing_component` (`id`)), 1452
The MySQL that generates the error:
INSERT INTO civicrm_mailing (domain_id , reply_id , unsubscribe_id , optout_id , name , from_name , from_email , replyto_email , subject , body_text , body_html , is_template , url_tracking , forward_replies , auto_responder , open_tracking , is_completed ) VALUES (......
As we can see, CiviMail is reasonably not inserting a value into "header_id" (Since we are not using a header), however the FK expects there to be a header_id no matter what.
The best solution would be if there where a way to modify the FK so that it only cares about the FK if header_id is non-null. We could then insert "header_id" as NULL on the query if there are no headers being used. However, i'm not sure you can make a FK behave like this.