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

dev/core#1383: Fix Re-Installation of Extensions With Logging Enabled #15816

Conversation

MiyaNoctem
Copy link
Contributor

Overview

If logging is enabled, CiviCRM will create log tables for every table in the CiviCRM Schema. If an extension added custom groups and fields, logging tables for those custom groups will be created. When the extension is uninstalled, custom groups and fields will get deleted. However, logging tables will remain unaffected. This may be desireable behaviour (ie. keeping the log of tables that used to exist in DB), but if the extension is re-installed, current handling of custom fields will cause a DB error, as fields will try to be added again to the logging tables as duplicates.

Before

When uninstalling an extension, logging tables associated to custom groups and fields will not be deleted. On re-installation, addition of custom fields will cause DB errors to be thrown, as columns existing on logging tables are tried to be created again (they already exist on logging tables, as they were never removed).

After

Fixed by checking if the column exists on log table before trying to create it, treating it as a modification of the schema if it exists.

@civibot
Copy link

civibot bot commented Nov 11, 2019

(Standard links)

@civibot civibot bot added the master label Nov 11, 2019
@MiyaNoctem MiyaNoctem force-pushed the dev-core-1383-fix-reinstallation-of-extensions-with-logging branch 2 times, most recently from 9d6dd74 to 465aeda Compare November 11, 2019 16:15
@eileenmcnaughton
Copy link
Contributor

@MiyaNoctem I haven't had a chance to look at this yet - but my take is it should probably be against 5.20 branch as I think it's a regression?

@MiyaNoctem MiyaNoctem changed the base branch from master to 5.20 November 21, 2019 12:00
@civibot civibot bot added 5.20 and removed master labels Nov 21, 2019
@MiyaNoctem MiyaNoctem changed the base branch from 5.20 to master November 21, 2019 12:01
@civibot civibot bot added master and removed 5.20 labels Nov 21, 2019
When uninstalling an extension, logging tables associated to custom groups and
fields will not be deleted. On re-installation, addition of custom fields will
cause DB errors to be thrown, as columns existing on logging tables are tried
to be created again (they already exist on logging tables).

Fixed by checking if the column exists on log table before trying to create
it, treating it as a modification of the schema if it exists.
@MiyaNoctem MiyaNoctem force-pushed the dev-core-1383-fix-reinstallation-of-extensions-with-logging branch from 465aeda to 363c450 Compare November 21, 2019 12:48
@MiyaNoctem MiyaNoctem changed the base branch from master to 5.20 November 21, 2019 12:52
@civibot civibot bot added 5.20 and removed master labels Nov 21, 2019
@MiyaNoctem
Copy link
Contributor Author

@eileenmcnaughton I've re-based the fix on v5.20 release candidate branch.

@eileenmcnaughton
Copy link
Contributor

This took a bit to replicate as I hit other problems on the extension I first tried it on (accountsync with some datefield issues in strict mode) before realising it only applies if the extension is installing AND uninstalling custom groups. A lot of extensions install custom groups - very few remove them on install but the one mentioned in the ticket attempts to (it actually fails though in my testing as they were not inconsistently removed). I wound up hacking the custom table our manually after uninstall and at that point hit the described issue on re-install.

I agree that this fixes it and that it seems like a sensible change. On review I think I was wrong in thinking this was an rc-issue as it doesn't seem like part of the seemingly-related issues but at this stage I'm going to merge as is (against the rc) anyway.

These are the enotices I got installing the extension

Screen Shot 2019-11-22 at 3 03 04 PM

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.

2 participants