Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Critical
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.7.5, 4.7.7
-
Fix Version/s: 4.7.8
-
Component/s: Core CiviCRM
-
Labels:
-
Documentation Required?:None
-
Funding Source:Contributed Code
Description
There are multiple reports of this bug in the wild:
http://civicrm.stackexchange.com/questions/11318/unable-to-upgrade-to-4-7-6
http://civicrm.stackexchange.com/questions/11522/upgrade-fails-4-7-4-4-7-6-in-wp-4-5-1
I was asked to investigate another instance of this, and have determined that there are two root causes, which is why this has proved difficult to solve on Stack Exchange.
First - the upgrade code in question (in CRM/Upgrade/Incremental/sql/4.7.5.mysql.tpl) attempts to drop existing FK constraints. Not everyone has those FK constraints. I couldn't find definitive evidence of why - the XML schema file in question doesn't have version numbers, and I don't have a Civi SVN archive. My guess is that when this table was added, the upgrade script didn't add foreign keys to existing sites.
Second - the upgrade code in CRM-18345 adds foreign key constraints - but doesn't first disable foreign key checks. That means that it fails if you've already met the very condition it's attempting to prevent.
To solve this definitively, the code should:
- Wrap the "DROP FOREIGN KEY" MySQL in a conditional (e.g.: http://stackoverflow.com/a/14072931/2832108)
- Disable foreign key checks while creating the new constraints (with "SET FOREIGN_KEY_CHECKS=0").
Attachments
Issue Links
- is supplemented by
-
CRM-18345 Deleting an email address deletes any mailing events related to it, and the contact
- Done/Fixed
- links to