Problem/Motivation

In PhpMail we have this

$additional_headers = isset($message['Return-Path']) && ($site_mail === $message['Return-Path'] || static::_isShellSafe($message['Return-Path'])) ? '-f' . $message['Return-Path'] : '';
      $mail_result = $this->doMail(
        $message['to'],
        $mail_subject,
        $mail_body,
        $mail_headers,
        $additional_headers
      );

And the signature of doMail is this

protected function doMail(string $to, string $subject, string $message, array|string $additional_headers = [], string $additional_params = ''): bool {

So on a cursory read, you would think that $additional_headers is passed to the

$additional_headers

param, but its not, its passed as $additional_params

Steps to reproduce

Read the current code and get confused.

Proposed resolution

Rename the local variable in mail from $additional_headers to $additional_params to match the signature of doMail and avoid the confusion.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#9 Param-changed.png19.79 KBurvashi_vora

Issue fork drupal-3345385

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

larowlan created an issue. See original summary.

larowlan credited cafuego.

larowlan’s picture

cafuego’s picture

Status: Active » Needs review

Made a PR with a simple variable rename.

urvashi_vora’s picture

Assigned: Unassigned » urvashi_vora

I will review the MR.

urvashi_vora’s picture

Assigned: urvashi_vora » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new19.79 KB

I reviewed the MR.

Steps performed while reviewing:-
1. Taken clone of issue branch
2. Reviewed PHPMail.php file as per Merge Request 3750.
3. On line number 124 and 130, the param $additional_headers is changed to $additional_params.
4. Attaching the screenshot for reference.

Test Result:- Pass.
Moving it to RTBC.

The MR looks good to me, and it is ready to be merged.

Thanks for the work.

  • larowlan committed f76bfd35 on 10.0.x
    Issue #3345385 by cafuego: Local variable $additional_headers in PhpMail...

  • larowlan committed f2e3f701 on 10.1.x
    Issue #3345385 by cafuego: Local variable $additional_headers in PhpMail...

  • larowlan committed b3eb566f on 9.5.x
    Issue #3345385 by cafuego: Local variable $additional_headers in PhpMail...
larowlan’s picture

Version: 10.1.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Thanks committed to 10.1.x and backported to 9.5.x to keep things consistent as there's little risk of disruption here

larowlan’s picture

Status: Fixed » Closed (fixed)

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