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#2757 test to demonstrate contact delete actions not called for v4 api #21137

Closed
wants to merge 1 commit into from

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Aug 14, 2021

Overview

Per https://lab.civicrm.org/dev/core/-/issues/2757 it turns out that our tests were hiding the fact that calling Contact.delete using v4 api wasn't calling the right delete BAO actions (in this case deleting inherited memberships).

This PR just demonstrates this in a unit test

Before

After

Technical Details

@colemanw I thought we had addressed this ?

Comments

@civibot
Copy link

civibot bot commented Aug 14, 2021

(Standard links)

@civibot civibot bot added the master label Aug 14, 2021
@eileenmcnaughton
Copy link
Contributor Author

As expected

image

@colemanw
Copy link
Member

colemanw commented Aug 20, 2021

Digging in...
This is slightly alarming: evidently APIv4 has never called any BAO::del() methods the way APIv3 did. It has always done its own thing (originally that thing was to call ->delete() directly on a new DAO object, more recently it calls the new DAO::deleteRecords() method, which also circumvents the old del() functions.
This is mitigated by the fact that most of the del() methods don't do very much.

@colemanw
Copy link
Member

I want to fix this the right way. And as tempting as it would be, the quick-fix of calling $baoName::del() isn't a good idea IMO. Having skimmed through them just now, some of the del() functions are alarming in their own right!

The end-game here is to have a single generic deleteRecord() function which calls pre/post hooks, and each BAO can register listeners to do their pre/post processing, instead of shoving that logic into del() functions. I'm going to work on something which takes us in that direction as much as possible, while addressing this problem in a reasonable timeframe.

For starters, #21198 #21199 #21200

@colemanw
Copy link
Member

Discussion piece for the more complicated del() functions that contain business logic: #21201

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