-
Notifications
You must be signed in to change notification settings - Fork 6
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
Switch eck_sub_types OptionGroup to a managed entity #32
Conversation
This core patch should help make this sort of upgrade problem much easier in the future: civicrm/civicrm-core#22883 |
… before/after upgrade
…n errors before/after upgrade" This reverts commit 92fc980.
@jensschuppe right, unfortunately that doesn't work because the managed reconciliation happens before the upgrader runs. |
This is what needs to be done before reconciling managed entities with this PR: // Create managed entity for previously unmanaged eck_sub_types OptionGroup.
\Civi\Api4\Managed::create(FALSE)
->setValues([
'module' => 'de.systopia.eck',
'name' => 'OptionGroup_eck_sub_types',
'cleanup' => 'always',
'entity_type' => 'OptionGroup',
'entity_id' => \Civi\Api4\OptionGroup::get(FALSE)
->addSelect('id')
->addWhere('name', '=', 'eck_sub_types')
->execute()
->single()['id'],
])
->execute(); |
It depends on how you update the extension. Just dropping in the new code and running upgrades manually via the UI doesn't cause managed entities be reconciled until a manually triggered cache clear / menu rebuild. I'm not sure about That might still be a problem causing managed entities not being created when they're missing (i.e. come new with an update or in a more complicated scenario as ours). But that's a thing for core, I guess. @colemanw do you know when managed entities are being reconciled in the first place? |
My understanding is that managed entities get reconciled every time you do a full cache-clear, and at the end of every upgrade. I'm not sure why it's been happening for me before the upgrade runs (I've been using Lines 279 to 281 in 2d3756d
|
This answers @jensschuppe's question about how to create an option group using the CiviCRM Managed system.
NOTES:
.mgd.php
file is standard. Usehook_civicrm_managed
for "custom group extends" optionValues #30 worked directly in the hook code because it needed some logic to loop through the entitiy types. But normally the hook just scans this directory for.mgd.php
files and returns their contents.cleanup => always
so it will get auto-deleted on uninstall.CRM_Eck_CustomData
class is no longer used so I removed it. I assume it was copied over from another extension because it's quite large..mgd.php
file with the API Explorer. It's pretty cool: