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

[REF] Cleanup function for retrieving contact types. #17676

Merged
merged 1 commit into from
Jun 29, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Jun 21, 2020

Overview

Minor code cleanup intended to allow us to deprecate a couple of odd params in CRM_Core_DAO::executeQuery - naming $abort = FALSE & $daoName.

Before

Use of older methods

After

Retrieves using apiv4 - DB retrieves & caches once & filters as needed - should be so cheap as to not warrant caching the filtering

Technical Details

This switches to using the apiv4 as part of trying to eliminate calls to executeQuery where the DAO is passed in
like

       = CRM_Core_DAO::executeQuery(, [],
        FALSE, 'CRM_Contact_DAO_ContactType'
      );

Note that this file seems to be the only place this is done.

Also note that I added tests first & the changes to the test highlight what is changed in the PR in the output - namely

  • stricter type casting (courtesy apiv4)
  • same keys present for all types

Comments

@civibot
Copy link

civibot bot commented Jun 21, 2020

(Standard links)

@civibot civibot bot added the master label Jun 21, 2020
This switches to using the apiv4 as part of trying to eliminate calls to executeQuery where the DAO is passed in
like

```
       = CRM_Core_DAO::executeQuery(, [],
        FALSE, 'CRM_Contact_DAO_ContactType'
      );
```

Note that this file seems to be the only place this is done.

Also note that I added tests first & the changes to the test highlight what is changed in the PR in the output - namely
- stricter type casting (courtesy apiv4)
- same keys present for all types
@seamuslee001
Copy link
Contributor

Jenkins re test this please

* @throws \API_Exception
*/
protected static function getAllContactTypes() {
if (!Civi::cache('contactTypes')->has('all')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton do we need to bust this cache whenever a contact type is enabled or disabled or deleted or does the system already do that sensibly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already doing Civi::cache('contactTypes')->clear();

@seamuslee001
Copy link
Contributor

This seems fine to me and unit tests should cover us here I think

@seamuslee001 seamuslee001 merged commit fcb1a2d into civicrm:master Jun 29, 2020
@seamuslee001 seamuslee001 deleted the ct branch June 29, 2020 22:31
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