Postponing on #3276953: Add tests of new release emails
Problem/Motivation
I got an email titled New release(s) available for [my site's title]. However, the email body started with There was a problem checking available updates for Drupal.
Checking further, there were in fact no updates available.
- If Drupal was unable to confirm the need for updates, the email title should not say "new releases available".
- If Drupal has security updates pending, the email title should state that it is a security notice.
Steps to reproduce
Proposed resolution
When there is any security update available the subject contains "Security release(s) available for"
When all of the attempts to get release information fail, the subject contains "Failed to get release information for"
In all other cases the subject contains "New release(s) available for". In the case the body may still contain a message about failing to get release information.
Remaining tasks
- Land #3538637: Fix problems with UpdateMailTest: only test valid cases, use correct paths, remove dead code
- Rebase this MR
- Reviews / refinements
- RTBC
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #67 | 1818764-nr-bot.txt | 1.47 KB | needs-review-queue-bot |
| #63 | 1818764-nr-bot.txt | 1.88 KB | needs-review-queue-bot |
| #49 | Screenshot 2024-04-15 at 10.05.48 AM.png | 361.29 KB | smustgrave |
Issue fork drupal-1818764
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
Anonymous (not verified) commentedMoving to D8.
Comment #2
haydeniv commentedI am wondering if we should even send an email notification if there is a problem checking for updates.
Comment #3
Anonymous (not verified) commentedI can see the point of emailing if the user wants to be notified via email. The title does need to reflect the true nature of the issue or changed to a more generic text; e.g. Message from Drupal's Update module.
Comment #4
haydeniv commentedLet's try this "Update notice for !site_name" for the subject line. Short sweet and generic.
Comment #5
Anonymous (not verified) commentedI think it's a bit too short. How about "System site update notice for !site_name" instead? The "System site" gives more context to the message.
Comment #6
haydeniv commentedI'm confused as to what a "System site" is. Maybe "Site update notice for...". Site names can start to get pretty long and subject lines are meant to be short and concise. http://www.businessweek.com/articles/2012-06-28/the-art-of-the-e-mail-subject-line says subject lines should be shorter than 50 characters. With "System site" addition that makes it 29 characters before the site name and to me !site_name is really important if I am administering a dozen or so Drupal sites. Thoughts?
Comment #7
Anonymous (not verified) commentedOkay, if we want short then "Site notice for ..." is better. The "update" word doesn't need to be present in the subject. A side issue could be addressing the message body as a result of the subject change.
Comment #8
haydeniv commentedSounds good to me.
Comment #9
xurizaemonRe-rolling this patch with an addition that makes security updates (= UPDATE_NOT_SECURE or UPDATE_REVOKED for any module currently needing update) stand out by altering the subject to 'Security notice for !site_name' (d8) or 'Security update(s) available for !site_name' (d7).
D7 backport may not be accepted because string freeze, but attaching it anyway.
Note that the existing update_mail() appends (
$message['subject'] .=) and this patch assigns. It's not clear from the existing code why it appended, and from my reading of drupal_mail() it would only be appending to empty string anyway, so AFAICT this is not a behaviour change.Comment #10
xurizaemonfix D8 patch, set do-not-test on D7 patch.
Comment #13
xurizaemonComment #14
xurizaemonComment #15
xurizaemonComment #16
dman commentedVisually #10 looks very sensible - Can't imagine how it could be wrong.
But as identified in a (sprint) discussion - we can't imagine a practical way to TEST this exact situation - We would need two emails being generated with and without a 'security' level notice - given the state of any test system, and the state of the d.o update feeds.
Is this even possible? is it WAY too difficult, or can we just be sane and put this in as 'sensible'?
I can't locate any pre-existing unit tests that wrap the current functionality, so generally feel like this is good - but I can't prove it.
Comment #19
superspring commentedComment #20
amitgoyal commentedReroll of #10.
Comment #21
xurizaemonThanks for rerolling Amit!
Comment #22
xurizaemonRerolling for reduced fuzz.EDIT: Failing at Git. Ignore this :D
Comment #24
xurizaemonRerolling for reduced fuzz :D
Comment #25
xurizaemonComment #26
mgiffordNeeds re-roll.
Comment #27
xurizaemonre-roll
Comment #28
mgiffordComment #39
quietone commentedComment #40
quietone commentedIgnore that patch, I left in testing code.
Comment #41
quietone commentedPostponing on #3276953: Add tests of new release emails
Comment #44
quietone commentedConverted latest patch to an MR and added tests.
The test no longer uses exact counts for the calls to the mocked functions because they vary so much now. If exact counts are wanted they would have to be added to the data provider array. That doesn't seem necessary to me for this test.
Comment #45
smustgrave commentedShould a follow up be opened to add back in a different way for performance measuring? Seems like coverage we could be losing.
Comment #46
smustgrave commentedRan the tests locally since I can't trigger test-only on the MR
Failed asserting that two strings are identical.
Expected :'Site notice for Test site'
Actual :'New release(s) available for Test site'
Change there seems fine so going to mark, but still wonder about a follow up.,
Comment #47
dwwHrm, "Site notice for @site_name" seems pretty unhelpful and very easy to ignore.
I'm in favor of adding "security" to the subject in the case of missing security updates, but the other change here seems like a step backwards, not forwards.
The original report was a complaint that it shouldn't say "New releases(s) available for @site_name" if there was a problem checking for updates. That could be fixed by checking the reason code (like we're now doing to detect missing security updates) and change the subject if it's an error to fetch.
Also, if this is really a bug, the title of this issue probably shouldn't be "improve update status email subject". 😅 If that's the scope of the issue, it should be a task, not a bug. And the new subject should actually be an improvement. 😂
IMHO, either we should focus on fixing the originally reported bug (that the subject shouldn't say "New release(s) available..." if there's a problem checking for updates), or we should change this to a task and make real improvements.
Sorry,
-Derek
Comment #48
quietone commented@dww, thanks for the review.
I am leaving this as a bug since it is odd to get a message with a subject that releases are available when the body says that there was trouble getting the release information. I have updated the proposed resolution with my idea for handing this.
Comment #49
smustgrave commentedCouldn't run test-only feature but ran locally shouldn't "contrib, fetch fail" and "core fetch fail" fail also?
Comment #50
quietone commentedIn this case they should not fail. Prior to this change there were no tests for fetching failures. These test are showing that the existing behavior does not change when there are both updates and fetch failures. That is, the email subject will always announce that new releases are available even if there are fetch failures for another project.
Comment #51
smustgrave commentedThanks for following up #quietone. In that case believe this is good.
Comment #52
xjmThanks @smustgrave for the manual testing and question; @quietone's response helped me understand the logic better.
I've posted just a few small improvements to grammar on the MR, plus typehinted the rest of the test method. It's on the wobbly line for scope but we're allowed to break test hint signatures at any point, and it helped me understand the data provider structure for reviewing all the new cases. (Plus it will save work down the road.)
Once those are fixed up I think this is ready.
Comment #53
xjmSaving issue credits.
Comment #55
xjmThanks @pradhumanjain2311 for your contributions. The point of suggestions is for the existing contributors to the issue to have a chance to +1 the reviewer's suggested changes. A person who has not otherwise contributed to the issue just clicking buttons to apply the suggestions does not really help move the issue forward. Therefore, I won't be crediting this contribution. In the future, you can receive credit by providing a review of an issue with open questions.
Marking NR for one of the issue's contributors to review the applied suggestions.
Comment #56
smustgrave commentedDoes appear as suggestions were applied.
Comment #57
xjm@smustgrave, again, I don't need validation that the suggestions were applied -- I can see that from the tooling -- I need validation that they were good suggestions. Thanks! :)
Comment #58
smustgrave commentedLeft comments on the threads
3 agree, 1 I'm 50/50, 1 I made a suggestion.
Comment #59
smustgrave commentedThe 1 suggestion can be done probably directly from gitlab but didn't move to NW @xjm agree on it?
Comment #60
smustgrave commentedMoving to NW for the 1 suggestion, which seems like a good task. Also could use a rebase being 300+ commits behind.
Comment #61
dhruv.mittal commentedComment #62
dhruv.mittal commentedI have resolved merge conflicts and rebased it please have a look.
Comment #63
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #65
danrodI fixed most of the issues reported by the Queue Bot, but there's still a PHPSTAN issue to fix: https://git.drupalcode.org/issue/drupal-1818764/-/jobs/5007233
Where is this function
_update_manager_accessimplemented? was it ever implemented in this MR? I think it's a legacy function from D7 that needs to be refactored here:Comment #66
quietone commentedComment #67
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #69
nexusnovaz commentedI resolved the issue that the review bot raised however there is the nightwatch test failing. Unsure if its just glitching and a rerun is fine, or if its because we're behind on commits?
Comment #70
quietone commented@nexusnovaz, A failing Nightwatch test is not related to the change here and is likely one of the random fails that exist. You can either re-run the test or add a comment that the failed tests are unrelated and then set the issue to 'needs review'.
Comment #71
smustgrave commentedFeedback appears to be addressed on this one.
Comment #72
xjmThis is sort of disruptive in its way (it will start bypassing existing mail filters), so let's have a change record for it. It should also be committed to 11.x only. Thanks!
Comment #73
dwwThis is getting close. Pushed a few commits to resolve a few more of the open threads. Down to 1 (the request for inline comments describing each case in
UpdateMailTest::providerTestUpdateEmail()).Also, opened #3538637: Fix problems with UpdateMailTest: only test valid cases, use correct paths, remove dead code which I noticed while reviewing this. That's totally out of scope here, but should happen.
Comment #74
dwwInitial CR: https://www.drupal.org/node/3538659
Comment #75
dwwOkay, did some more sleuthing, and decided that 2 of the existing cases in this test are totally bogus, as is 1 of the new ones we added:
_update_cron_notify()is the only place sends the 'status_notify' email.$paramsarray.hook_mail()implementation without parameters.Removed all 3 cases, and the related @todo comments from my attempt to document everything.
Apologies for the possible scope creep. Perhaps we should postpone this on a new follow-up just to fix all the brokenness in this test, then circle back to fix the bug and expand the test. But it seemed more prudent to fix them all in 1 shot.
With the draft CR done, all MR threads resolved, and a green pipeline, this is ready for review again. 😅
Comment #76
dwwPer Slack chat with @xjm, postponing this bug fix on #3538637: Fix problems with UpdateMailTest: only test valid cases, use correct paths, remove dead code, which I've re-scoped into fixing
UpdateMailTestbefore we try to expand it here.Comment #77
dwwAnyone following this issue: #3538637: Fix problems with UpdateMailTest: only test valid cases, use correct paths, remove dead code is now ready for review if anyone is willing to give it a look. Thanks!
Comment #81
dwwTrying to make progress while we wait for #3538637: Fix problems with UpdateMailTest: only test valid cases, use correct paths, remove dead code to land.
The old branch had massive conflicts when trying to rebase it on top of #3538637. So I opened a new branch, added a single commit for #3538637, then 2 commits for the merged results of that and the previous MR branch, 1 for the change to set the subject, one for the test coverage. Once 3538637 is in 11.x, it'll be easy to interactive rebase this to remove that 1 commit, then we'll have an easy 2 commits here to review...
Comment #82
dwwThe blocker, #3538637: Fix problems with UpdateMailTest: only test valid cases, use correct paths, remove dead code, is now in 11.x. I rebased MR 12950 to clean that up. This should be ready for review now.
Comment #83
dwwComment #84
znerol commentedSetting to needs work for the @todo and the follow-up (see MR comments).
Comment #85
znerol commentedMade the follow-up: #3553063: _update_message_text() calls Url::fromRoute without options.
Comment #86
znerol commentedHow about this for the @todo: