Do not log an error message when no emails are specified for update notifications

Created on 8 July 2024, 3 months ago
Updated 16 July 2024, 3 months ago

Problem/Motivation

As the website administrator, I don't want to see a log message every time the cron runs when I specified no email addresses for the notification.

Steps to reproduce

  • Configure Update Manager on the Update Manager settings page (/admin/reports/updates/settings)
  • Make sure that there is no emails specified in the "Email addresses to notify when updates are available" field
  • run the cron
  • observe a watchdog message with
    1. Type - mail
    2. Message - Error sending email (from mail@example.com to with reply-to not set).
    3. Severity - Error

Proposed resolution

Improve configuration form save function to filter out empty lines.

Remaining tasks

Add a test that the message is logged without the fix and is not logged with the fix.

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Closed: duplicate

Version

11.0 πŸ”₯

Component
UpdateΒ  β†’

Last updated about 9 hours ago

  • Maintained by
  • πŸ‡ΊπŸ‡ΈUnited States @tedbow
  • πŸ‡ΊπŸ‡ΈUnited States @dww
Created by

πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @RoSk0
  • Pipeline finished with Canceled
    3 months ago
    Total: 227s
    #219260
  • Issue was unassigned.
  • Status changed to Needs review 3 months ago
  • πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington
  • Pipeline finished with Failed
    3 months ago
    Total: 555s
    #219263
  • Status changed to Needs work 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Appears to have test failures but seems like a fix that will need test coverage.

  • First commit to issue fork.
  • πŸ‡§πŸ‡·Brazil murilohp

    Hi! I was also having this issue and the MR fixes the problem, I was not able to write a properly test to trigger the exact error:
    Error sending email (from mail@example.com to with reply-to not set).
    This would require us to send an e-mail on a test suite, and this is not possible. So, instead of trying to replicate the same issue, the test tries to save the "Email addresses to notify when updates are available" field with an empty value and validates the exact thing that's being saved.

    Before the fix, saving the field empty would result on something like:

    $this->config('update.settings')->get('notification.emails') = [
      0 => ""
    ];
    

    With the fix, it would be like:

    $this->config('update.settings')->get('notification.emails') = [];
    
  • Pipeline finished with Success
    3 months ago
    Total: 557s
    #221390
  • πŸ‡§πŸ‡·Brazil murilohp

    murilohp β†’ changed the visibility of the branch 3460081 to hidden.

  • πŸ‡§πŸ‡·Brazil murilohp

    murilohp β†’ changed the visibility of the branch 3460081 to active.

  • Status changed to Needs review 3 months ago
  • πŸ‡§πŸ‡·Brazil murilohp

    Since the all tests passed, I'm moving this back to NR.

    FYI: I've created another branch with the test only, but I don't know how to trigger the build on gitlab for that branch only, and when I try to compare the branch, for some reason I can't open a new MR. It's been while since my last contribution and a lot has changed, if you guys have any docs or tutorials about how to properly use gitlab, it would be great for me. Thanks!

  • Status changed to RTBC 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Ran the test-only feature

    1) Drupal\Tests\update\Functional\UpdateSettingsFormTest::testUpdateSettingsForm
    Failed asserting that two arrays are identical.
    --- Expected
    +++ Actual
    @@ @@
    -Array &0 []
    +Array &0 [
    +    0 => '',
    +]
    /builds/issue/drupal-3460081/core/modules/update/tests/src/Functional/UpdateSettingsFormTest.php:102
    FAILURES!
    Tests: 1, Assertions: 47, Failures: 1.
    

    Which does show the coverage.

    Using the array filter appears to fix the issue described.

    LGTM

  • Status changed to Needs work 3 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    The issue summary states that the problem is that there is an unwanted/unnecessary log message. There should be a test here that this fix does indeed prevent that message from displaying.

    I was also wondering if this message should change to an information level message to remind sites that the email address is not set. Any thoughts on that?

    I have restored the issue summary template so I can add remaining tasks.

  • Status changed to Closed: duplicate 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States dww

    I believe this is duplicate with πŸ› Cron tries to send update notification email while no email is set Needs work . Let's concentrate our efforts over there.

    Thanks!
    -Derek

Production build 0.71.5 2024