-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
hook_managed - do not try to disable managed entities if is_active is not available to api3.create #20144
Conversation
(Standard links)
|
cleanup=never
on disableEntities
@eileenmcnaughton test fail relates here
|
@seamuslee001 yeah - but I don't know whether to try to fix that or not as @totten said he is commenting & I'm waiting on that |
OK, so restating context for comprehension/clarity... the general idea of a "managed entity" is for the entity lifecycle to track the extension (ie update, enable, disable, remove in tandem with the owner ext). The use-case you described (disabling an APIv4-only entity) does sound problematic, though from my POV it raises another issue. Narrowly, Anywho, it sounds like the approach here is -- "If
Hypothetically, you could have a flag for the activate/deactivate behavior, eg
This current PR re-purposes the IIRC, the other case for opting-out of
Suppose, for example, that you're trying to use |
@totten so activate doesn't exist but you are suggesting it could? |
Note that I'm just adding this at this stage - but when we enable we need to configure the right monolog loggers - see the readme for what we get by default To add a wmf logger we will need to add a new monolog logger and then we can, for example, do Civi::log('wmf')->debug('merging contacts 1 & 2') And that will be output to whatever is configured for channel 'wmf' with debug or lower as minimum severity. The firephp thing is kinda fun. Known issues - I planned to replace failmail too but we have an out of date version of phpmailer so I didn't bring it into scope on this round - Error on disable civicrm/civicrm-core#20144 - Notice on enable civicrm/civicrm-core#20122 - I wanted to create a full edit form but pending https://lab.civicrm.org/dev/core/-/issues/2567 - And I wanted to display the configured below the add - https://lab.civicrm.org/dev/core/-/issues/2569 Current commit https://lab.civicrm.org/extensions/monolog/-/commit/d7ff4a06c28af7cb84007e992b471566b995df67 Bug: T279983 Change-Id: I981513ea506a6484871b9db13d769bbf8c7927b6
cleanup=never
on disableEntities
@totten after digging into adding 'activate' handling I realised it was getting pretty tricky as the mgd data was already gone by the time I needed it (I guess another DB field might be needed). As a stop gap I have resolved the FIXME in the code |
I think this needs reviewing/looking at in conjunction with #19676 |
It's the same class but it doesn't directly interact |
@totten I guess this PR & @mattwire's PR (#19676) both need tests - but it would be good for you to confirm the approach for both PRs. I found the test class kinda hard going but I'll dig in again if you confirm this is otherwise OK & I'm sure @mattwire will be happy to write a test for his PR if he knows the same |
@eileenmcnaughton Yeah, I think this approach looks pretty good. You had flagged this for prioritization before 5.38 flips to RC (which is ASAP). If we're aiming for the test now -- that means we push to 5.39? (Or, if you want, we might squeeze this one into 5.38 and then merge UT to 5.38.beta?) I've added some comments/suggestions on |
@totten if you merge this now I'll take a look at a test as follow up |
OK, I'm giving it an |
@totten easies r-run is with monolog extension https://github.com/eileenmcnaughton/monolog |
Well, I'd made a couple throw-away extensions to test this. The first created a new entity-type/table ( function civicrm_api3_apple_create($params) {
if (isset($params['is_active'])) {
throw new \API_Exception("We should not be called with is_active!");
}
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Apple');
} The second extension had two managed-entities:
The patch correctly skipped de-activation. However, it still produced re-activation. I've added a couple commits to fix that as well. I tried various workflows of enable/disable/uninstall steps... and they seemed to work as I expected. @eileenmcnaughton, if the updates are OK with you, then let's merge. |
Thanks @totten - looks good - I was aware that the scope was pretty narrow so that is great. |
I'll try again at those tests |
Looks like this missed the forking after all - ah well - we tried |
I made good on my promise to add a unit test - #20320 - although in the end this PR could have stayed open waiting for the test as it didn't hit the rc anyway |
Overview
Only try to disable disable-able entities from managed
Respect cleanup = never on disableEntitiesBefore
Currently cleanup=never is respected on ininstall but not on disableAfter
Check is done to ensure the entity can be disabled (using v3 api)
Technical Details
I'm hitting this as a bug on a cleanup=never entity which has a v4 api and not a v3 api so it could be
solved using more failure tolerance in the disable function or checking more values/ entity availability
We discussed adding the 'activate' key and while I think that is a good idea I hit some implementation issues - I couldn't see how to do that without adding a field to civicrm_managed since the information is otherwise unavailable at the right time.
However, I did note that I could resolve a TODO in the code and at the same time ameliorate the issue I was dealing with
However, I actually think the intuitive meaning of cleanup = never is 'never try to clean this up' and I don't see why that would apply to uninstall & not disable
Comments
@totten @colemanw