From 4b156d619f63f549d9300469a3ab65af27410167 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Wed, 11 Sep 2019 22:12:04 +0200 Subject: [PATCH] Fix param docs and passed type of UserMailer::sendWithPear Mail::send accepts mixed for recipients and only array for headers The documentation for recipients allows string with comma-separated list or a string array https://github.com/pear/Mail/blob/master/Mail/mail.php#L115-L119 Change-Id: Ia8269e91a7dcfe09d41bd03f8830b83f28812564 --- includes/mail/UserMailer.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/includes/mail/UserMailer.php b/includes/mail/UserMailer.php index 47fa16f87f..07830683fd 100644 --- a/includes/mail/UserMailer.php +++ b/includes/mail/UserMailer.php @@ -34,8 +34,8 @@ class UserMailer { * Send mail using a PEAR mailer * * @param Mail_smtp $mailer - * @param string $dest - * @param string $headers + * @param string[]|string $dest + * @param array $headers * @param string $body * * @return Status @@ -382,6 +382,8 @@ class UserMailer { throw new MWException( 'PEAR mail package is not installed' ); } + $recips = array_map( 'strval', $to ); + Wikimedia\suppressWarnings(); // Create the mail object using the Mail::factory method @@ -397,13 +399,13 @@ class UserMailer { $headers['Subject'] = self::quotedPrintable( $subject ); // When sending only to one recipient, shows it its email using To: - if ( count( $to ) == 1 ) { - $headers['To'] = $to[0]->toString(); + if ( count( $recips ) == 1 ) { + $headers['To'] = $recips[0]; } // Split jobs since SMTP servers tends to limit the maximum // number of possible recipients. - $chunks = array_chunk( $to, $wgEnotifMaxRecips ); + $chunks = array_chunk( $recips, $wgEnotifMaxRecips ); foreach ( $chunks as $chunk ) { $status = self::sendWithPear( $mail_object, $chunk, $headers, $body ); // FIXME : some chunks might be sent while others are not! -- 2.20.1