Closed (fixed)
Project:
Webform
Version:
8.x-5.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 Jun 2019 at 18:05 UTC
Updated:
16 Jun 2019 at 16:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
panchoA hot candidate might be #3051865: Email handler ignores selected theme.
Let's try three patches:
Comment #3
panchoWhat do we learn from this?
We obviously need to dig deeper.
Comment #4
panchoI traced this back to 5.0.0-rc27 (November 2018) where WebformBrowserTestBaseTest was introduced. So it seems this bug has existed for quite some time, and only came to the light with the new test coverage.
Fortunately it seems this is mostly a test artefact, as the tests are hardcoding a particular order of emails, while for some reason, emails are sent in a divergent order:
I tweaked WebformBrowserTestBase::getLastEmail() a bit, so I got to see more than just the very last email.
I'm also fixing the argument order of two assertEquals() calls. The expected value needs to be first.
This however doesn't fix the test failure here, and I'm not trying to hide it. We still have to fix the order emails are sent out.
Comment #5
panchoOK, I think I found it, and it was very simple:
The email_confirmation and email_notification handlers in the yml files both have a weight of 1, so while they are not called in an outright arbitrary order, the order seems to be determined by hardly predictable circumstances.
Enclosed patch tests green locally, both under PHP 5.6 and PHP 7.2.
tests-only patch should fail.
Comment #6
panchoYay!
Here's just another iteration avoiding code duplication on WebformHandlerEmailRenderingTest::testEmailRendering(). I think it's easier to grasp like that, but feel free to pick whatever you want from here.
Comment #7
panchoComment #8
jrockowitz commentedThere is too much going on in this patch. We should not have reorder how emails are being sent to pass a test. I am going to turn on automatted tests for PHP5.
Comment #9
panchoIn that case, the simple alternative is:
rather than only reading the very last email when testing, read the last two emails, no matter in which order they were sent, figure our which is which, and run the test on the correct one.
However, from my point of view, this is not just about fixing our tests. We need to ensure predictability, otherwise not only our tests will fail, but also custom or contrib code's expectations.
Sorry about that. Once we figured whether to fix our default config or just fix our tests, I will provide a patch that is stripped down to the minimum necessary.
Comment #10
jrockowitz commentedI think fixing the handler weight in the webform.contact.yml should fix the issue.
Comment #11
jrockowitz commentedSorry please ignore the patch from #10.
Comment #12
panchoSince recently, D8.8 doesn't support PHP 5.5 anymore. Only D8.6 and D8.7 do.
Comment #14
jrockowitz commentedI committed the patch from #11 which should fix the PHP5 issue.
Comment #15
jrockowitz commentedComment #16
panchoNice.
I added the following four followups for all parts of patch #6 that ultimately didn't make it into the commit: