From 9cbf84879ef058339f3383ca9bca52e85b33bed5 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 29 Apr 2015 07:56:20 -0700 Subject: [PATCH] Add PEAR's Mail and Mail_Mime to composer.json's suggestions Bug: T97454 Change-Id: Ib9f0f5329249b504814d08638f5b7fbde091344c --- composer.json | 4 +++- includes/mail/UserMailer.php | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 005ae7f3fc..c4a5470f42 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,9 @@ "ext-mbstring": "*", "ext-wikidiff2": "*", "ext-apc": "*", - "monolog/monolog": "*" + "monolog/monolog": "*", + "pear/mail": "*", + "pear/mail_mime": "*" }, "autoload": { "psr-0": { diff --git a/includes/mail/UserMailer.php b/includes/mail/UserMailer.php index d83ae93624..7f8341aa6d 100644 --- a/includes/mail/UserMailer.php +++ b/includes/mail/UserMailer.php @@ -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(); -- 2.20.1