Add PEAR's Mail and Mail_Mime to composer.json's suggestions
authorChad Horohoe <chadh@wikimedia.org>
Wed, 29 Apr 2015 14:56:20 +0000 (07:56 -0700)
committerBryanDavis <bdavis@wikimedia.org>
Fri, 14 Aug 2015 17:42:53 +0000 (17:42 +0000)
Bug: T97454
Change-Id: Ib9f0f5329249b504814d08638f5b7fbde091344c

composer.json
includes/mail/UserMailer.php

index 005ae7f..c4a5470 100644 (file)
@@ -43,7 +43,9 @@
                "ext-mbstring": "*",
                "ext-wikidiff2": "*",
                "ext-apc": "*",
-               "monolog/monolog": "*"
+               "monolog/monolog": "*",
+               "pear/mail": "*",
+               "pear/mail_mime": "*"
        },
        "autoload": {
                "psr-0": {
index d83ae93..7f8341a 100644 (file)
@@ -241,7 +241,10 @@ class UserMailer {
                                // remove the html body for text email fall back
                                $body = $body['text'];
                        } else {
-                               require_once 'Mail/mime.php';
+                               # Check if pear/mail_mime is already loaded (via composer)
+                               if ( !class_exists( 'Mail_mime' ) ) {
+                                       require_once 'Mail/mime.php';
+                               }
                                if ( wfIsWindows() ) {
                                        $body['text'] = str_replace( "\n", "\r\n", $body['text'] );
                                        $body['html'] = str_replace( "\n", "\r\n", $body['html'] );
@@ -278,14 +281,14 @@ class UserMailer {
                }
 
                if ( is_array( $wgSMTP ) ) {
-                       #
-                       # PEAR MAILER
-                       #
-
-                       if ( !stream_resolve_include_path( 'Mail.php' ) ) {
-                               throw new MWException( 'PEAR mail package is not installed' );
+                       # Check if pear/mail is already loaded (via composer)
+                       if ( !class_exists( 'Mail' ) ) {
+                               # PEAR MAILER
+                               if ( !stream_resolve_include_path( 'Mail.php' ) ) {
+                                       throw new MWException( 'PEAR mail package is not installed' );
+                               }
+                               require_once 'Mail.php';
                        }
-                       require_once 'Mail.php';
 
                        MediaWiki\suppressWarnings();