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

  1. Land #3538637: Fix problems with UpdateMailTest: only test valid cases, use correct paths, remove dead code
  2. Rebase this MR
  3. Reviews / refinements
  4. RTBC

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-1818764

Command icon 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

Anonymous’s picture

Version: 7.16 » 8.x-dev
Issue tags: +Needs backport to D7

Moving to D8.

haydeniv’s picture

I am wondering if we should even send an email notification if there is a problem checking for updates.

Anonymous’s picture

I 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.

haydeniv’s picture

Title: Wrong email title when there is a problem checking updates » Wrong email subject line when there is a problem checking updates
Status: Active » Needs review
StatusFileSize
new853 bytes

Let's try this "Update notice for !site_name" for the subject line. Short sweet and generic.

Anonymous’s picture

I 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.

haydeniv’s picture

I'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?

Anonymous’s picture

Okay, 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.

haydeniv’s picture

StatusFileSize
new851 bytes

Sounds good to me.

xurizaemon’s picture

Title: Wrong email subject line when there is a problem checking updates » Better subject line for site updates
Issue summary: View changes
StatusFileSize
new1.25 KB
new1.28 KB

Re-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.

xurizaemon’s picture

fix D8 patch, set do-not-test on D7 patch.

The last submitted patch, 9: drupal-1818764-update_email_subject-drupal8.patch, failed testing.

The last submitted patch, 9: drupal-1818764-update_email_subject-drupal7.patch, failed testing.

xurizaemon’s picture

Title: Better subject line for site updates » Correct & improve update status email subject
xurizaemon’s picture

Issue tags: +Drupal8NZ
xurizaemon’s picture

Issue summary: View changes
dman’s picture

Visually #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.

Status: Needs review » Needs work

The last submitted patch, 10: drupal-1818764-update_email_subject-drupal8.patch, failed testing.

superspring’s picture

Issue tags: +Needs reroll
amitgoyal’s picture

Status: Needs work » Needs review
StatusFileSize
new1.33 KB

Reroll of #10.

xurizaemon’s picture

xurizaemon’s picture

Rerolling for reduced fuzz.

EDIT: Failing at Git. Ignore this :D

Status: Needs review » Needs work

The last submitted patch, 22: drupal-1818764-update_email_subject-drupal8_22.patch, failed testing.

xurizaemon’s picture

Status: Needs work » Needs review
StatusFileSize
new1.33 KB

Rerolling for reduced fuzz :D

xurizaemon’s picture

Issue summary: View changes
mgifford’s picture

Status: Needs review » Needs work

Needs re-roll.

xurizaemon’s picture

mgifford’s picture

Status: Needs work » Needs review

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Version: 9.3.x-dev » 10.0.x-dev
Issue summary: View changes
Issue tags: +Bug Smash Initiative
StatusFileSize
new2.13 KB
quietone’s picture

StatusFileSize
new1.36 KB

Ignore that patch, I left in testing code.

quietone’s picture

Issue summary: View changes
Status: Needs review » Postponed
Issue tags: +Needs tests

Version: 10.0.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Title: Correct & improve update status email subject » improve update status email subject
Status: Postponed » Needs review
Issue tags: -Needs tests

Converted 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.

smustgrave’s picture

The test no longer uses exact counts for the calls to the mocked functions because they vary so much now.

Should a follow up be opened to add back in a different way for performance measuring? Seems like coverage we could be losing.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Ran 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.,

dww’s picture

Status: Reviewed & tested by the community » Needs work

Hrm, "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

quietone’s picture

Title: improve update status email subject » Use specific subject line in update emails
Issue summary: View changes
Status: Needs work » Needs review

@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.

smustgrave’s picture

Status: Needs review » Needs work
StatusFileSize
new361.29 KB

tests

Couldn't run test-only feature but ran locally shouldn't "contrib, fetch fail" and "core fetch fail" fail also?

quietone’s picture

Status: Needs work » Needs review

In 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.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Thanks for following up #quietone. In that case believe this is good.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Thanks @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.

xjm’s picture

Saving issue credits.

pradhumanjain2311 made their first commit to this issue’s fork.

xjm’s picture

Status: Needs work » Needs review

Thanks @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.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Does appear as suggestions were applied.

xjm’s picture

Status: Reviewed & tested by the community » Needs review

@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! :)

smustgrave’s picture

Left comments on the threads

3 agree, 1 I'm 50/50, 1 I made a suggestion.

smustgrave’s picture

The 1 suggestion can be done probably directly from gitlab but didn't move to NW @xjm agree on it?

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Novice

Moving to NW for the 1 suggestion, which seems like a good task. Also could use a rebase being 300+ commits behind.

dhruv.mittal’s picture

Assigned: Unassigned » dhruv.mittal
dhruv.mittal’s picture

Assigned: dhruv.mittal » Unassigned
Status: Needs work » Needs review

I have resolved merge conflicts and rebased it please have a look.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.88 KB

The 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.

danrod made their first commit to this issue’s fork.

danrod’s picture

I 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

 ------ --------------------------------------------------------------------- 
  Line   core/modules/update/update.module                                    
 ------ --------------------------------------------------------------------- 
  207    Function _update_manager_access not found.                           
         🪪  function.notFound                                                
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  

Where is this function _update_manager_access implemented? was it ever implemented in this MR? I think it's a legacy function from D7 that needs to be refactored here:

/**
 * Access callback: Resolves if the current user can access updater menu items.
 *
 * It both enforces the 'administer software updates' permission and the global
 * kill switch for the authorize.php script.
 *
 * @return
 *   TRUE if the current user can access the updater menu items; FALSE
 *   otherwise.
 *
 * @see update_menu()
 */
function update_manager_access() {
  return variable_get('allow_authorize_operations', TRUE) && user_access('administer software updates');
}
quietone’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.47 KB

The 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.

nexusnovaz made their first commit to this issue’s fork.

nexusnovaz’s picture

I 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?

quietone’s picture

Status: Needs work » Needs review

@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'.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Feedback appears to be addressed on this one.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Novice +Needs change record

This 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!

dww’s picture

This 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.

dww’s picture

dww’s picture

Status: Needs work » Needs review

Okay, 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.
  • It returns early if there are no values in the $params array.
  • It therefore seems pointless to unit test our 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. 😅

dww’s picture

Title: Use specific subject line in update emails » [PP-1] Use specific subject line in update emails
Issue summary: View changes
Status: Needs review » Postponed
Issue tags: -Needs backport to D7

Per 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 UpdateMailTest before we try to expand it here.

dww’s picture

Anyone 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!

dww changed the visibility of the branch 1818764-correct--improve to hidden.

dww’s picture

Trying 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...

dww’s picture

Status: Postponed » Needs review

The 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.

dww’s picture

Title: [PP-1] Use specific subject line in update emails » Use specific subject line in update emails
znerol’s picture

Status: Needs review » Needs work

Setting to needs work for the @todo and the follow-up (see MR comments).

znerol’s picture

How about this for the @todo:

diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index 1a217fa54da..b492d4f6ba3 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -214,6 +214,9 @@ function _update_message_text($msg_type, $msg_reason, $langcode = NULL) {
     case UpdateFetcherInterface::NOT_CHECKED:
     case UpdateFetcherInterface::NOT_FETCHED:
     case UpdateFetcherInterface::FETCH_PENDING:
+      // @todo Conditionally generate absolute URL when used in email context
+      // and pass language option to Url::fromRoute().
+      // @see https://drupal.org/i/3553063
       if ($msg_type == 'core') {
         $text = t('There was a problem checking <a href=":update-report">available updates</a> for Drupal.', [':update-report' => Url::fromRoute('update.status')->toString()], ['langcode' => $langcode]);
       }

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.