Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Core/Dev 18# where logging fails if the AUTO INCREMENT column is … #11865

Merged
merged 1 commit into from
Apr 4, 2018

Conversation

seamuslee001
Copy link
Contributor

…not named id and add tests

Overview

Previously if a table that was captured by the Log table creation regex that named its AUTO INCREMENT column something other than id there would be database errors generated as it tried to reconcile the log table schema with the current schema because it didn't do any proper handling for AUTO INCREMENT columns

Before

DB Errors generated when reconciling schema

After

No DB errors

ping @agileware @eileenmcnaughton @JoeMurray

I think this makes sense the case that showed this up is enabling the civicrm membership role sync and then turning on detailed logging. Then proceeding to do a CiviCRM upgrade and it fails as it tries to reconcile the log tables to the main table and in this function unlike the function that initially creates the tables there was no special handling for AUTO INCREMENT

@jusfreeman
Copy link
Contributor

@seamuslee001 thanks!

This bug is a fairly major PITA. I agree with any fix for it. Thanks Mr. Fixit :)

@eileenmcnaughton
Copy link
Contributor

@jusfreeman are you able to test / review it / assign someone to so we can get it merged?

@jusfreeman
Copy link
Contributor

@eileenmcnaughton can do after the weekend.

@eileenmcnaughton
Copy link
Contributor

You don't take weekends off do you? Slacker :-)

@JoeMurray
Copy link
Contributor

Doing visual code review the logic looks good.

@jusfreeman
Copy link
Contributor

@seamuslee001 @eileenmcnaughton

I was able to verify this patch works for both a CiviCRM 4.7.31 and a CiviCRM 4.6.32 site which had an existing log_civicrm_member_roles_rules table.

Without the patch applied and attempting to enable logging, the following error is reported to civicrm.log. Interestingly, logging is still enabled after the error.

[code] => -1 [message] => DB Error: unknown error [mode] => 16 [debug_info] => ALTER TABLEcivicrm.log_civicrm_member_roles_rules MODIFY rule_idint(11) AUTO_INCREMENT [nativecode=1075 ** Incorrect table definition; there can be only one auto column and it must be defined as a key] [type] => DB_Error [user_info] => ALTER TABLEcivicrm.log_civicrm_member_roles_rules MODIFY rule_idint(11) AUTO_INCREMENT [nativecode=1075 ** I ncorrect table definition; there can be only one auto column and it must be defined as a key] [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info=" ALTER TABLEcivicrm.log_civicrm_member_roles_rules MODIFY rule_idint(11) AUTO_INCREMENT [nativecode=1075 ** Incorrect table defi nition; there can be only one auto column and it must be defined as a key]"]

After the patch is applied, logging is enabled without error. Patch can be applied to both CiviCRM 4.7 and CiviCRM 4.6.

This problem would only impact on Drupal websites which have the CiviCRM member roles sync module enabled and I expect, having upgraded from older versions of CiviCRM.

The test environments already had an existing log_civicrm_member_roles_rules table. I tried to set up clean environment but was unable to get the log_civicrm_member_roles_rules table created, trying various methods.

Agileware Ref CIVICRM-838

@eileenmcnaughton
Copy link
Contributor

@jusfreeman thanks for the review - I'm just having trouble interpretting

"The test environments already had an existing log_civicrm_member_roles_rules table. I tried to set up clean environment but was unable to get the log_civicrm_member_roles_rules table created, trying various methods."

Does that indicate any reservation about this patch or just a side note?

@jusfreeman
Copy link
Contributor

Does that indicate any reservation about this patch or just a side note?

No reservations. I could only trigger the issue when the log_civicrm_member_roles_rules table exists in the database. If it is absent, no issue.

Just thought it curious that log_civicrm_member_roles_rules table could not be created in a "clean" environment.

@eileenmcnaughton
Copy link
Contributor

OK - I'm going to merge this based on your testing & the (yay) sensible addition of a unit test. I don't think this would affect that side- issue.

Thanks @seamuslee001 @jusfreeman

@eileenmcnaughton eileenmcnaughton merged commit a794f62 into civicrm:master Apr 4, 2018
@eileenmcnaughton eileenmcnaughton deleted the core_dev_18 branch April 4, 2018 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants