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#1280 Fix ContributionPage soft_credit translation #16838

Merged
merged 2 commits into from
Jul 17, 2020

Conversation

mlutfy
Copy link
Member

@mlutfy mlutfy commented Mar 18, 2020

Overview

https://lab.civicrm.org/dev/core/issues/1280

To reproduce:

  • Enable multilingual (Admin > Localisation > languages, checkbox at the bottom)
  • Add a second language (Admin > Localisation > Languages, 'available languages')
  • Create a Contribution Page
    • Enable "Honoree Section Enabled"
    • Enter a title/description, types
    • save

Now switch languages, edit text and save.

Result: data disappears or in wrong language.

inhonor-of-translation

@civibot civibot bot added the master label Mar 18, 2020
@civibot
Copy link

civibot bot commented Mar 18, 2020

(Standard links)

@mlutfy
Copy link
Member Author

mlutfy commented Apr 3, 2020

jenkins, test this please

$this->assertEquals($json['soft_credit']['en_US']['honor_block_title'], 'In Honor Title EN');
$this->assertEquals($json['soft_credit']['en_US']['honor_block_text'], 'In Honor Text EN');
$this->assertEquals($json['soft_credit']['fr_FR']['honor_block_title'], 'In Honor Title FR');
$this->assertEquals($json['soft_credit']['fr_FR']['honor_block_text'], 'In Honor Text FR');
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the test - just these params are backwards. Expected is the first param. When it fails it's briefly confusing.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

$ufJoinDAO = new CRM_Core_DAO_UFJoin();
$ufJoinDAO->module = $ufJoinParam['module'];
$ufJoinDAO->entity_id = $ufJoinParam['entity_id'];
$ufJoinDAO->find(TRUE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible that soft-credit profiles could be used for something other than contribution pages? If so, you'd want to take entity_table into account. It used to before with the deleteAll. Otherwise this might match on multiple and might update the wrong one.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the combo would be surprising, but I added an extra check, just in case.
However, I only did a quick code edit, need to re-test.

@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

@demeritcowboy what's your take on this - it looks like you reviewed it - is it pending a response from @mlutfy
?

@eileenmcnaughton
Copy link
Contributor

@mlutfy style issues...

@demeritcowboy
Copy link
Contributor

demeritcowboy commented Jul 14, 2020

I don't remember running it just code review. Yes, one clerical, one functional. I must have run the test at least.

@mlutfy
Copy link
Member Author

mlutfy commented Jul 16, 2020

Keeping a copy in case it disappears too quickly:

Capture d’écran de 2020-07-16 18-27-08

@mlutfy mlutfy force-pushed the core1280 branch 3 times, most recently from 1ca3fd8 to 0c0aed6 Compare July 16, 2020 22:33
@mlutfy
Copy link
Member Author

mlutfy commented Jul 16, 2020

Thanks for the review @demeritcowboy !

I updated my PR with the recommandations:

  • switched the order of the test params
  • added an extra check for the ufParams (entity_table)
  • fixed the styling

I just need to do one last test to make sure that adding the extra check didn't break anything.

@mlutfy
Copy link
Member Author

mlutfy commented Jul 17, 2020

I did a bit more testing and it seems to be working as expected.

@eileenmcnaughton
Copy link
Contributor

@mlutfy please self-merge once @demeritcowboy gives this a thumbs up

@demeritcowboy
Copy link
Contributor

demeritcowboy commented Jul 17, 2020

@mlutfy I think you've found an awesomely sneaky way of getting tests to pass. Just name the file slightly differently than the actual test class. The test framework won't even run it! Easy pass. (FYI @totten @seamuslee001 )

The test runs fine if you run it manually.

So either the file or the classname needs to be renamed, but otherwise all good.

@mlutfy
Copy link
Member Author

mlutfy commented Jul 17, 2020

Yikes, good catch 😬

Note to self: in the full test log, ctrl-F for ContributionPageTranslationTest

@demeritcowboy
Copy link
Contributor

Looks good. So I think this is now "merge-on-pass".

@mlutfy
Copy link
Member Author

mlutfy commented Jul 17, 2020

Thanks again, @demeritcowboy, very much appreciated!

@mlutfy
Copy link
Member Author

mlutfy commented Jul 17, 2020

Tests have not completed yet, but seeing this now:

ok 600 - CRM_Contribute_Form_ContributionPageTranslationTest::testCreateHonor

@demeritcowboy
Copy link
Contributor

Cool.

And actually if you have a minute #17806 just needs an r-run and that's the last piece before the outputhandler stuff is ready.

@mlutfy mlutfy merged commit 26c9d07 into civicrm:master Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants