Problem/Motivation

Update Status policy crashes in Drupal 11 due to missing update_requirements().

Error: Call to undefined function Drupal\symfony_mailer\Plugin\EmailBuilder\update_requirements() in .../modules/contrib/symfony_mailer/src/Plugin/EmailBuilder/UpdateEmailBuilder.php on line 64 #0 [internal function]: Drupal\symfony_mailer\Plugin\EmailBuilder\UpdateEmailBuilder->build()

(This location is from 1.6.x release but 2.x/src/Plugin/Mailer/UpdateMailer.php is also affected.)

Issue #3500632: Convert hook_requirements() that do not interact with install time removed hooks from update.install, including update_requirements(), and replaced them with Drupal\update\Hook\UpdateRequirements. These calls will need to be replaced in the mailer policies.

Steps to reproduce

Install Drupal 11.2.0 or higher and enable the Update Status mailer policy. Drupal will crash when attempting to send a status email message.

I'm reluctant to elevate priority on this, but this has been causing cron runs to crash in my production environment.

Proposed resolution

This bug can be mitigated by disabling the Update Status policy and letting Drupal core generate the email message text.

Calls to update_requirements() will need to be replaced with calls to (I think) UpdateRequirements::runtime(), but I am not sure that the new autowired hook services can be injected as dependencies, so I currently have no recommendations about how to make this work.

Remaining tasks

User interface changes

API changes

Data model changes

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

micahw156 created an issue. See original summary.

micahw156’s picture

Issue summary: View changes
danchadwick’s picture

Priority: Normal » Major

This issue is quite severe depending upon configuration. If a production site uses the update manager to send emails, then cron will crash, resulting in a total loss of cron activity (and the pollution of the error logs with many php errors). In my site, this means that none of the automatic processing the site requires happens, resulting in a near-complete loss of functionality.

There priority guidelines for critical require that there be no workaround, so raising to major.

micahw156’s picture

@danchadwick, I was able to mitigate this problem by disabling the update status override at admin/config/system/mailer/override which reverts update emails to Drupal Core's original unformatted state and allows cron to run without errors.

Micah

danchadwick’s picture

@micahw156 - Yes, I saw that in the issue and did mitigate it as such. Without such a mitigation, it would definitely warrant critical priority. Thank you for your report.

adamps’s picture

The problem is that Core doesn't provide an API for the information that we need. So I had to call an internal function, which has now been removed. We can check the issue that removed it to see if it explains the replacement to use.

adamps’s picture

It looks like we could do something like this

if (function_exists('update_requirements')) {
  $requirements = update_requirements('runtime');
}
else {
  $requirements = \Drupal::moduleHandler()->invoke('update', 'runtime_requirements');
}

My sites are still on D10 so I can't test it.

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

robloach’s picture

Status: Active » Needs review
StatusFileSize
new813 bytes

Here's the patch.

robloach’s picture

StatusFileSize
new868 bytes

And here is the patch for 1.x

adamps’s picture

Status: Needs review » Needs work

The MR appears to have no commits.

sah62’s picture

I'm running 1.6.2. The 1.x patch seems to be working for me.

johnny5th’s picture

The patch works great but exposes another issue:
UpdateEmailBuilder provides a link to the update manager, which has been removed in 11.2.

if (Settings::get('allow_authorize_operations', TRUE)) {
      $email->setVariable('update_manager', Url::fromRoute('update.report_update')->toString());
    }
adamps’s picture

@johnny5th Good point. We can check if the route exists, or just catch the RouteNotFoundException.

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

oulalahakabu’s picture

Status: Needs work » Needs review

MRs done.

adamps’s picture

Thanks. Would be great if someone else could test.

#13 is still open. It could be put into a separate issue, but would be nicer to add it here if possible.

adamps changed the visibility of the branch 3535562-symfony_mailer to hidden.

adamps changed the visibility of the branch 3535562-symfony_mailer to active.

adamps changed the visibility of the branch 3535562-symfony_mailer-1.x to hidden.

adamps changed the visibility of the branch 3535562-update-status-mailer to hidden.

adamps’s picture

Thanks everyone. I have fixed the extra problem from #13 and it all looks good.

  • adamps committed a7851526 on 2.x authored by oulalahakabu
    #3535562 Update Status mailer policy broken by core hooks modernization
    
adamps’s picture

Title: Update Status mailer policy broken by core hooks modernization » Update Status mails broken by core hooks modernization
Component: Policy » Code
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

majid.ali made their first commit to this issue’s fork.

majid.ali’s picture

StatusFileSize
new2.48 KB

Issue still persist in 1.x after updating to Drupal 11.2. Same reason as for 2.x the route update.report_update has been removed https://www.drupal.org/node/3511861 and throws error Route "update.report_update" does not exist.. Pushed the fix in MR https://git.drupalcode.org/project/symfony_mailer/-/merge_requests/184/d... and added static patch as well.

allow_authorize_operations is deprecated in 12 https://www.drupal.org/node/3571399 and it will be removed.

nojj’s picture

I have the same issue with a Drupal 11.3.7 site and Mailer 1.6.2.

what patch do I need to fix this?

the site does not crash, but the mails are not sent.