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/mail/6) On multilingual mode, choosing mailing group doesn't affect recipient count and list #11906

Merged
merged 1 commit into from
Apr 1, 2018

Conversation

monishdeb
Copy link
Member

Overview

Steps to reproduce

  1. Enable multilingual mode
  2. Go to Mailing => New Mailing
  3. Choose one or more mailing group.

Please check https://lab.civicrm.org/dev/mail/issues/6

Before

test-multiple-before

After

test-multiple-after

@monishdeb monishdeb added the 5.0 label Mar 31, 2018
@monishdeb
Copy link
Member Author

monishdeb commented Mar 31, 2018

@seamuslee001 yes you are right, that's another bug we need to squash :D Will include the fix in this PR shortly. Thanks for pointing that out.

@seamuslee001
Copy link
Contributor

@monishdeb
Copy link
Member Author

@seamuslee001 interesting fact - that function isn't used anywhere, heres what I got on grep

Monishs-MacBook-Pro:civicrm monish$ grep -irn "hiddenMailingGroup(" CRM/ api/ Civi/ tests/ 
CRM//Mailing/BAO/Mailing.php:2887:  public static function hiddenMailingGroup($mid) {

only one occurence where this fucntion is declared not get called. This might be when some code dropped it's call. I think we should get rid of this function, what you say?

@seamuslee001
Copy link
Contributor

@monishdeb i think you might be right looks like this was where it was originally called from https://github.com/fuzionnz/civicrm-svn/blob/4e48c95f7026d0a7930397189d4640d29c73bf6a/CRM/Mailing/Form/Group.php#L205 it might have changed when @totten did his angular work on CiviMail

@monishdeb
Copy link
Member Author

Done removed the fn

@gljk
Copy link

gljk commented Mar 31, 2018

Does this testing fail mean I shouldn't deploy this change in the production environment just yet?
I applied it locally and it seems to work.

@monishdeb
Copy link
Member Author

@gljk usually yes that's what the test build tells if the patch is safe to use. But in this case it doesn't seem to be case, as the failing unit-test isn't related and has been the case in other PRs in past, as I call. So let me rebuild the test build on this PR and I am pretty sure that it will pass in next build :)

(I believe this patch is safe to deploy in prod.)

@monishdeb
Copy link
Member Author

Jenkins test this please

@gljk
Copy link

gljk commented Apr 1, 2018

Great! Tested and everything works just fine in real life conditions.

@eileenmcnaughton
Copy link
Contributor

I'm merging this based on @gljk testing & because the code seems clear cut & correct. I also did the grep test on the removed function

@eileenmcnaughton eileenmcnaughton merged commit daeea75 into civicrm:5.0 Apr 1, 2018
@@ -128,8 +128,9 @@ public static function getRecipients($mailingID) {
$recipientsGroup = $excludeSmartGroupIDs = $includeSmartGroupIDs = $priorMailingIDs = array();
$dao = CRM_Utils_SQL_Select::from('civicrm_mailing_group')
->select('GROUP_CONCAT(entity_id SEPARATOR ",") as group_ids, group_type, entity_table')
->where('mailing_id = #mailing_id AND entity_table IN ("civicrm_group", "civicrm_mailing")')
->where('mailing_id = #mailing_id AND entity_table IN ("!groupTableName", "civicrm_mailing")')
Copy link
Member

@totten totten Apr 2, 2018

Choose a reason for hiding this comment

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

@monishdeb @seamuslee001 I have no mechanism for demonstrating the frequency/distribution in real-world scenarios, but the list of valid values for civicrm_mailing_group.entity_table allows any mix of civicrm_group, civicrm_group_en_US, civicrm_group_fr_FR, civicrm_mailing -- e.g. one might get a mix by:

  • Interleaving steps of (a) composing/reusing mailings and (b) toggling multilingual support.
  • Composing/previewing/delivering messages with different users (and different default locales).
  • Enabling integrations/extensions that work with mailing APIs (but aren't clever about multilingual)

Shouldn't this really be a pattern-match?

->where('mailing_id = #mailing_id AND entity_table RLIKE "^civicrm_(group.*|mailing)$"')

(Aside: The data model is evil.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that could work. I also wonder do we need the AND entity_table IN etc if we can only have 2 types of values groups and mailings and we are including both here.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably figure out how we can add appropriate testing for these things since otherwise we are always gonna hit more

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh right, so using RLIKE pattern will be flexible enough to tackle mix of group table name values (i.e. w/o locale part the case on toggling multilingual mode). Will create a separate PR with this fix also with UT to use getRecipients() on multilingual test env.

Copy link
Contributor

Choose a reason for hiding this comment

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

@monishdeb I wonder what we could do to see what happens when we run our WHOLE SUITE in another lingua

Copy link
Member Author

Choose a reason for hiding this comment

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

@eileenmcnaughton I have submitted a PR #11924 in this regard. Extended a UT to ensure that switching to multilingual mode in and then reusing the existing mail draft won't affect recipient list building.

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