Comments

jeroent’s picture

Status: Active » Needs review
StatusFileSize
new5.81 KB

First attempt on removing the drupal_mail_system usages. Patch attached.

rpayanm’s picture

StatusFileSize
new1.35 KB
new7.16 KB

I found other occurrences.

quietone’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, no instances of drupal_mail_system(), except for function itself. Passed tests.

Seems simple enough that I've changed status to RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Lots of the comments can be reflowed to fit the 80 character limit. NB. Only change lines the patch is changing.

Here are the fixes I would make:

diff --git a/core/includes/mail.inc b/core/includes/mail.inc
index 9b6388b..a661e72 100644
--- a/core/includes/mail.inc
+++ b/core/includes/mail.inc
@@ -14,10 +14,10 @@
  * and possibly email headers) and the replacement values to use in the
  * appropriate places in the template. Processed email templates are
  * requested from hook_mail() from the module sending the email. Any module
- * can modify the composed email message array using hook_mail_alter().
- * Finally \Drupal::service('plugin.manager.mail')->getInstance()->mail() sends
- * the email, which can be reused if the exact same composed email is to be sent
- * to multiple recipients.
+ * can modify the composed email message array using hook_mail_alter(). Finally
+ * \Drupal::service('plugin.manager.mail')->getInstance()->mail() sends the
+ * email, which can be reused if the exact same composed email is to be sent to
+ * multiple recipients.
  *
  * Finding out what language to send the email with needs some consideration.
  * If you send email to a user, her preferred language should be fine, so
diff --git a/core/lib/Drupal/Core/Mail/MailManagerInterface.php b/core/lib/Drupal/Core/Mail/MailManagerInterface.php
index 0972ce3..50645ab 100644
--- a/core/lib/Drupal/Core/Mail/MailManagerInterface.php
+++ b/core/lib/Drupal/Core/Mail/MailManagerInterface.php
@@ -22,9 +22,9 @@
    * appropriate places in the template. Processed email templates are requested
    * from hook_mail() from the module sending the email. Any module can modify
    * the composed email message array using hook_mail_alter(). Finally
-   * \Drupal::service('plugin.manager.mail')->mail() sends the email,
-   * which can be reused if the exact same composed email is to be sent to
-   * multiple recipients.
+   * \Drupal::service('plugin.manager.mail')->mail() sends the email, which can
+   * be reused if the exact same composed email is to be sent to multiple
+   * recipients.
    *
    * Finding out what language to send the email with needs some consideration.
    * If you send email to a user, her preferred language should be fine, so use
@@ -111,8 +111,8 @@
    *   If TRUE, \Drupal::service('plugin.manager.mail')->mail() will call
    *   \Drupal::service('plugin.manager.mail')->mail() to deliver the message,
    *   and store the result in $message['result']. Modules implementing
-   *   hook_mail_alter() may cancel sending by setting
-   *   $message['send'] to FALSE.
+   *   hook_mail_alter() may cancel sending by setting $message['send'] to
+   *   FALSE.
    *
    * @return string
    *   The $message array structure containing all details of the message. If
diff --git a/core/modules/system/src/Tests/Mail/MailTest.php b/core/modules/system/src/Tests/Mail/MailTest.php
index fb0727a..26cc34f 100644
--- a/core/modules/system/src/Tests/Mail/MailTest.php
+++ b/core/modules/system/src/Tests/Mail/MailTest.php
@@ -39,7 +39,6 @@ public function testPluggableFramework() {
     \Drupal::config('system.mail')->set('interface.default', 'test_php_mail_failure')->save();
 
     // Get the default MailInterface class instance.
-
     $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'default', 'key' => 'default'));
 
     // Assert whether the default mail backend is an instance of the expected
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index 0cbf698..1856f9a 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -305,10 +305,9 @@ function hook_contextual_links_plugins_alter(array &$contextual_links) {
  *
  * Email messages sent using functions other than drupal_mail() will not
  * invoke hook_mail_alter(). For example, a contributed module directly
- * calling the \Drupal::service('plugin.manager.mail')->mail()
- * or PHP mail() function will not invoke this hook. All core modules use
- * drupal_mail() for messaging, it is best practice but not mandatory
- * in contributed modules.
+ * calling the \Drupal::service('plugin.manager.mail')->mail() or PHP mail()
+ * function will not invoke this hook. All core modules use drupal_mail() for
+ * messaging, it is best practice but not mandatory in contributed modules.
  *
  * @param $message
  *   An array containing the message data. Keys in this array include:
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index d6a3942..31d7054 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -1290,8 +1290,8 @@ function user_role_revoke_permissions($rid, array $permissions = array()) {
  *   language.
  *
  * @return
- *   The return value from \Drupal::service('plugin.manager.mail')->mail(),
- *   if ends up being called.
+ *   The return value from \Drupal::service('plugin.manager.mail')->mail(), if
+ *   ends up being called.
  */
 function _user_mail_notify($op, $account, $langcode = NULL) {
   // By default, we always notify except for canceled and blocked.
rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new4.86 KB
new7.15 KB
quietone’s picture

@alexpott, @rpayanm, I see.

Reviewed patch from #5, it easier to read now. And grep still only found the declaration of the function drupal_mail_system().

ianthomas_uk’s picture

Status: Needs review » Reviewed & tested by the community

New patch addresses alex's comment

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Can someone attach the relevant change record?

ianthomas_uk’s picture

Status: Needs work » Reviewed & tested by the community

It was refactored in two steps, so two CRs attached.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue is a prioritized change (removal of deprecated functions) as per https://www.drupal.org/core/beta-changes and it's benefits outweigh any disruption. Committed feaabe2 and pushed to 8.0.x. Thanks!

  • alexpott committed feaabe2 on 8.0.x
    Issue #2358993 by rpayanm, JeroenT: Remove usage of drupal_mail_system()
    

Status: Fixed » Closed (fixed)

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