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

ManagedEntities - Allow "match" param to convert existing records to … #22883

Merged
merged 1 commit into from
Mar 5, 2022

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Mar 3, 2022

Overview

This can help ease the pain of declaring managed entities which may or may not already exist - now they can be matched by name or other unique identifier.

Before

An increasingly common scenario is to want to use the CiviCRM_Managed subsystem to declare entities which were previously created in some other way. For example, an extension may have inserted a record into the database during the install process. Later on, it seems like a good idea to move it into a .mgd.php file instead, but what to do about existing sites which have already run the installer?

After

Setting the match param will cause CiviCRM_Managed to look for an existing record before inserting a new one.

…managed entities

This can help ease the pain of declaring managed entities which may or may not
already exist - now they can be matched by name or other unique identifier.
@civibot
Copy link

civibot bot commented Mar 3, 2022

(Standard links)

@jmcclelland
Copy link
Contributor

+1 Yes, this is really useful. I just tried backporting it our 5.45 install and my extension that was failing this morning. And, IT WORKS! Thanks @Coleman.

@totten
Copy link
Member

totten commented Mar 5, 2022

Thanks for testing, @jmcclelland!

I like the concept, too, and the phpunit coverage looks pretty sensible.

Merging.

We'll need an update for https://docs.civicrm.org/dev/en/stable/hooks/hook_civicrm_managed/ -- but that can be post-merge.

@totten totten merged commit c531eb3 into civicrm:master Mar 5, 2022
@colemanw colemanw deleted the managedEntityMatch branch March 5, 2022 14:11
@colemanw
Copy link
Member Author

colemanw commented Mar 8, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants