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#1108 [REF] use CRM_Core_DAO::executeQuery instead of ->query() #14760

Merged
merged 1 commit into from
Jul 28, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Minor code cleanup

Before

Query translation done ad hoc in the function

After

Query translation done in standardised way by executeQuery

Technical Details

Fixes 2/4 places where this pattern is in the function. Fixing the last 2 will reduce cruft quite a bit

Comments

This allows us to leave the multilingual translation to the I18n rewriter. This PR just removes 2 instances from this function.

Once the others are removed we should be able to remove the swath of code defining I18n tables are the start of the function
and simplify the tables involved

Note testUnsubscribeGroupList passes through this code
@civibot
Copy link

civibot bot commented Jul 9, 2019

(Standard links)

@civibot civibot bot added the master label Jul 9, 2019
@pradpnayak
Copy link
Contributor

looks safe to merge

SELECT $mg.entity_table as entity_table,
$mg.entity_id as entity_id
FROM $mg
FROM civicrm_mailing_group $mg
Copy link
Contributor

Choose a reason for hiding this comment

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

@eileenmcnaughton this looks off to me, why are you specifiying the table name here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@seamuslee001 so as I understand it & @mlutfy can jump in if I am wrong we don't need to translate the table name - we just call CRM_Core_DAO::executeQuery and by default that has I10n handling on and it deals with it.

The reason THIS code has had to do all this mucking around is because it didn't want to conform & wanted to show independence by calling a retro function that doesn't handle I10n - but sometimes you just don't get to be an individual

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the other thing is what about when your coming via an extern URL? Like from the {mailing.opt_out_url} token. In those cases have we bootstrapped in all the CRM classes or just done require once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah - good thinking - we should test!

SELECT $group.id as group_id,
$group.title as title,
$group.description as description
FROM $group
LEFT JOIN $gc
FROM civicrm_group $group
Copy link
Contributor

Choose a reason for hiding this comment

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

Again why are we specifiying the table name here rather than in $group?

Copy link
Member

Choose a reason for hiding this comment

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

@eileenmcnaughton can you comment on this please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right so my understanding . is it was because we weren't relying on l10n in the query object - but @seamuslee001 believes it might not be available via extern path

@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 I did a search for this code & I can't see any evidence it's coming from the extern directory or any unbootstrapped paths.

Screen Shot 2019-07-25 at 6 09 58 PM

I stepped through the code by calling it from the api

Screen Shot 2019-07-25 at 6 13 20 PM

And you can see the query IS translated - ie the alias here is already translated so it goes from
FROM civicrm_group civicrm_group_US

to

FROM civicrm_group_US civicrm_group_US

Screen Shot 2019-07-25 at 6 25 16 PM

Screen Shot 2019-07-25 at 6 25 27 PM

SO I feel like swapping out the dao->query calls fro the std executeQuery IS the right way to stdise these

(@mlutfy )

@mlutfy
Copy link
Member

mlutfy commented Jul 25, 2019

I'm not familiar enough with the CRM_Core_DAO::query, but so far what I've seen makes sense. I've ran into multi-lingual + unsubscribe issues in the past, but they were hard to debug. This looks very familiar.

Regarding external paths, the unsubscribe page does fully bootstrap, no? (ex: it works in non-English)

I will deploy the patch to our production sites, so hopefully if this causes any regressions, we will find out before this goes to the next stable. Until then, I'm in favour of merging.

@seamuslee001
Copy link
Contributor

given @mlutfy 's comments i'm happy to merge this now and we will see what happens

@seamuslee001 seamuslee001 merged commit dd1ed5f into civicrm:master Jul 28, 2019
@seamuslee001 seamuslee001 deleted the unsub branch July 28, 2019 21:29
@eileenmcnaughton
Copy link
Contributor Author

thanks @seamuslee001

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.

5 participants