Problem/Motivation

The following PHP error is occurring when sending mail with Mime Mail:

Deprecated function: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\mimemail\Utility\MimeMailFormatHelper::mimeMailUrl() (line 598 of modules/contrib/mimemail/src/Utility/MimeMailFormatHelper.php).
Drupal\mimemail\Utility\MimeMailFormatHelper::mimeMailUrl() (Line: 211)
Drupal\mimemail\Utility\MimeMailFormatHelper::Drupal\mimemail\Utility\{closure}()
preg_replace_callback() (Line: 203)
Drupal\mimemail\Utility\MimeMailFormatHelper::mimeMailHtmlBody() (Line: 214)
Drupal\mimemail\Plugin\Mail\MimeMail->prepareMessage() (Line: 107)
Drupal\mimemail\Plugin\Mail\MimeMail->format() (Line: 43)
Drupal\mailsystem\Adapter->format() (Line: 291)
Drupal\Core\Mail\MailManager->doMail() (Line: 181)
Drupal\Core\Mail\MailManager->Drupal\Core\Mail\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 180)
Drupal\Core\Mail\MailManager->mail() (Line: 70)
Drupal\mailsystem\MailsystemManager->mail() (Line: 597)

Steps to reproduce

Drupal 11.2.5
PHP 8.3.14
Mimemail 2.0.0

We have a custom module that sends email notifications to reviewers when content nodes are updated. So try this recipe to reproduce:

1. Go to Configuration->System->Mail System and set the Formatter to "Mime Mail mailer".
2. Create a custom module that implements hook_entity_update()
3. In the hook_entity_update() function, send an email by calling \Drupal::service('plugin.manager.mail')->mail('employees', $key, $to, $langcode, $params, $from, true); (using appropriate values for those variables)
4. Edit and save a content node to trigger the hook_entity_update and send an email. The error is shown at the top of the next page.

I used xdebug to inspect MimeMailFormatHelper.php. On line 571, $url = "/node/25399/revisions/98313/view", which causes $query = null on line 573 and 598.

Proposed resolution

Change line 598 to

parse_str($query ?? "", $arr);

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork mimemail-3554648

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

richarddavies created an issue. See original summary.

santanu mondal’s picture

@
richarddavies I have check this no this Deprecated function: parse_str() type of log is not coming . So could you please provide me more details to produce this problem.

richarddavies’s picture

Issue summary: View changes

I've updated the issue description with more information on how to reproduce.

richarddavies’s picture

Issue summary: View changes

santanu mondal’s picture

Assigned: Unassigned » santanu mondal
santanu mondal’s picture

Assigned: santanu mondal » Unassigned
Status: Active » Needs review
santanu mondal’s picture

@richarddavies I have update the issue code so the warning gone please check .

richarddavies’s picture

Status: Needs review » Reviewed & tested by the community

Thank you, I reviewed and tested the updated MR and the warning is gone.

mark_fullmer’s picture

Status: Reviewed & tested by the community » Fixed

This change makes good sense. Merged. Thanks, folks!

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.