upgrade to 5.21.2 leads to deletion of custom fields (and data) defined in extensions via *.mgd.php files
This issues seems closely related to #1460 but is a more urgent variant so I thought it deserved a separate issue.
I have several extensions that provide custom data fields via *.mgd.php files.
The "cleanup" is set to "always" because, when the extension is deleted, I want the custom data to be deleted. That way people can try out the extension and if they don't like it, they can cleanly remove it and everything it created.
However we have a problem during upgrade:
- While in upgrade mode, at the end of the process,
reconcilegenerates a list of managed entities which at some point tries to call
- However, since we are in upgrade mode, only certain hooks are called - and
hook_civicrm_managedis not one of them.
reconcilethen compares the list of managed items in the database (which specifies the custom data fields that my extensions have defined and all have set the
cleanupfield 'always') with the list of managed entities defined by the the code base (which is none - because
hook_civicrm_manageddidn't run) and...
- Poof! All those custom fields are deleted along with all their data and option lists.
We didn't notice the data loss at first, so then had to re-construct the missing data which was quite tedious.
I see from #1460 that we are trying to leave out
hook_civicrm_managed because of some trouble with entities of the type PaymentProcessorType but, it seems that calling reconcile without
hook_civicrm_managed is always going to cause problems.