Update Notify fails to send email in AutomaticCron

Created on 13 May 2014, about 10 years ago
Updated 16 April 2024, 2 months ago

When using 8.x with the Update module active, the module will always see Drupal as not-up-to-date. Yet no email is ever sent, due to the following exception that gets thrown when the module causes AutomaticCron::onTerminate to be called, and the request time actually starts invoking cron jobs:

      if ($threshold > 0) {
        $cron_next = $this->state->get('system.cron_last', 0) + $threshold;
        if (REQUEST_TIME > $cron_next) {
          $this->cron->run();
        }
      }

While no mail goes out, the following error appears in the watchdog:

      wid: 47
      uid: 1
     type: cron
  message: %type: !message in %function (line %line of %file).
variables: a:6:{s:5:"%type";s:64:"Symfony\Component\DependencyInjection\Exception\RuntimeException";s:8:"!message";s:114:"You have requested a synthetic service ("request"). The DIC does not know how to construct this service.";s:9:"%function";s:43:"service_container_prod->getRequestService()";s:5:"%file";s:171:"/Users/rtoren/projects/drupal8/drupal/sites/default/files/php/service_container/service_container_prod/a1e224f690e8ddf15227b917194424a0d05132adc3cd5f3af47806f418a3aec5.php";s:5:"%line";i:3472;s:14:"severity_level";i:3;}
 severity: 3
     link:
 location:
  referer:
 hostname:
timestamp: 1399691972

The actual "point of death" is in PhpMail::mail():

    // For headers, PHP's API suggests that we use CRLF normally,
    // but some MTAs incorrectly replace LF with CRLF. See #234403.
    $mail_headers = join("\n", $mimeheaders);

    $request = \Drupal::request();

The problem here is the call to \Drupal::request(). I've been able to verify that sometime during the handling of onTerminate, the request object ceases to be available via \Drupal::request() (remember, onTerminate runs only after the browser has received output), if the object is even available. So PhpMail::mail() cannot be called right now this late in the history of the request

Not sure what the fix is, but pretty sure I have the cause down.

๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Updateย  โ†’

Last updated about 14 hours ago

  • Maintained by
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States @tedbow
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States @dww
Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States Torenware

Live updates comments and jobs are added and updated live.
  • Triaged core major

    There is consensus among core maintainers that this is a major issue. Only core committers should add this tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024