### Problem/Motivation

http://api.drupal.org/api/drupal/includes--mail.inc/function/drupal_mail/8

 $message = array(
    'id' => $module . '_' . $key, 

should be

 $message = array(
    'id' => $module . '__' . $key, 

That would make it easier to identify and alter emails, and could also avoid possible id collisions.

### Proposed resolution

### Remaining tasks

CommentFileSizeAuthor
#23 1237720-nr-bot.txt149 bytesneeds-review-queue-bot

Issue fork drupal-1237720

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

oadaeh’s picture

I'm trying to understand how creating every mail id with two underscores will make it easier to identify e-mails, alter e-mails, and avoid id collisions more than creating every mail id with with one underscore.

Would you please elaborate?

Pasqualle’s picture

for example
in hook_mail_alter you can alter mails by id.
If you try to alter all mails created by your module you may use

if (substr($id,0,9) == "mymodule_") {
  // Alter my mails.
}

but what if there is another module called "mymodule_other", then you will also alter mails of that module, which is not desired..

oadaeh’s picture

Something in my gut says you're doing it wrong, and I don't think you're going to get much support, but I could be wrong, so I'm going to leave the issue as is and let a core developer make the determining decision.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

jungle’s picture

Version: 8.9.x-dev » 9.1.x-dev
Category: Feature request » Bug report
Issue summary: View changes
Status: Active » Needs review
Issue tags: +Needs subsystem maintainer review, +Bug Smash Initiative

+1 to this.

  1. Applying IS template.
  2. The current dev branch is 9.1.x, changing the target version.
  3. This could be a bug, tagging "Bug Smash Initiative" per #2
  4. Tagging "Needs subsystem maintainer review" and setting to NR to get the direction of doing this or not.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Pasqualle’s picture

In D9 MailManager::doMail() has separate parameters for module and mail key, so it is possible to get those values in mail alter.
But I still think, the id should be with double underscores to avoid possible id collisions.

mymodule_other__key vs mymodule__other_key

Pasqualle’s picture

This should probably go to Drupal 10 as I would consider it as a breaking change.

Pasqualle’s picture

Version: 9.2.x-dev » 10.0.x-dev
Kristen Pol’s picture

I'm not clear why this was changed to a bug. This seems like a feature request IMO. @jungle?

Kristen Pol’s picture

It's not clear above but tests did pass even though #15 shows a failure. I assume @Pasqualle or someone reran the tests. You can see the success with a later time than the failure at the bottom of https://www.drupal.org/pift-ci-job/2006986.

But, this was tested on 9.2... do we need to test on 10?

longwave’s picture

I don't see how we can make this change in a backward-compatible way, or nor what bug it fixes - this just seems to be more disruptive than helpful. The IS mentions "possible ID collisions" but is this actually a real issue?

jungle’s picture

Category: Bug report » Support request
Issue tags: -Bug Smash Initiative
    $message = [
      'id' => $module . '_' . $key,
      'module' => $module,
      'key' => $key,
      'to' => $to,
      'from' => $site_mail,
      'reply-to' => $reply,
      'langcode' => $langcode,
      'params' => $params,
      'send' => TRUE,
      'subject' => '',
      'body' => [],
    ];

After checking into details of the related code, for the use case mentioned in #2, the module key of $message could be relied on, instead of depending on the id key as #14 pointed.

I'd say this is a won't fix, neither a bug nor a feature request.

Thanks!

Kristen Pol’s picture

Issue tags: +Bug Smash Initiative

Thanks for your input and workaround, @jungle. Afaik, we normally keep the Bug Smash Initiative tag even when switching to a support request so we know the bugsmash team worked on it.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
149 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

cilefen’s picture

Status: Needs work » Closed (outdated)

I am closing this based on #21.