From: Umherirrender Date: Wed, 11 Sep 2019 20:12:04 +0000 (+0200) Subject: Fix param docs and passed type of UserMailer::sendWithPear X-Git-Tag: 1.34.0-rc.0~242^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=4b156d619f63f549d9300469a3ab65af27410167 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 --- 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!