From 36a106d255587a558290b8a81218d6653fc2205d Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Thu, 28 Jul 2011 19:03:54 +0000 Subject: [PATCH] =?utf8?q?*=20followup=20r93397=20=E2=80=94=20missing=20$d?= =?utf8?q?est=20*=20Otherwise=20clean=20up=20$dest=20usage=20*=20Clean=20u?= =?utf8?q?p=20Debug=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- includes/UserMailer.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/includes/UserMailer.php b/includes/UserMailer.php index 4b8ee6b300..47e95b2f6c 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -143,11 +143,22 @@ class UserMailer { $headers['From'] = $from->toString(); $headers['Return-Path'] = $from->toString(); + $dest = array(); + if ( is_array( $to ) ) { + foreach ( $to as $u ) { + if ( $u->address ) { + $dest[] = $u->address; + } + } + } else if( $to->address ) { + $dest[] = $to->address; + } + if ( $wgEnotifImpersonal ) { $headers['To'] = 'undisclosed-recipients:;'; } else { - $headers['To'] = implode( ", ", (array )$dest ); + $headers['To'] = implode( ", ", $dest ); } if ( $replyto ) { @@ -180,15 +191,6 @@ class UserMailer { $msgid .= '.' . posix_getpid(); } - if ( is_array( $to ) ) { - $dest = array(); - foreach ( $to as $u ) { - $dest[] = $u->address; - } - } else { - $dest = $to->address; - } - wfSuppressWarnings(); // Create the mail object using the Mail::factory method @@ -199,8 +201,8 @@ class UserMailer { return Status::newFatal( 'pear-mail-error', $mail_object->getMessage() ); } - wfDebug( "Sending mail via PEAR::Mail to $dest\n" ); - $chunks = array_chunk( (array)$dest, $wgEnotifMaxRecips ); + wfDebug( "Sending mail via PEAR::Mail\n" ); + $chunks = array_chunk( $dest, $wgEnotifMaxRecips ); foreach ( $chunks as $chunk ) { $status = self::sendWithPear( $mail_object, $chunk, $headers, $body ); if ( !$status->isOK() ) { @@ -244,7 +246,7 @@ class UserMailer { return Status::newFatal( 'php-mail-error', self::$mErrorString ); } elseif ( ! $sent ) { // mail function only tells if there's an error - wfDebug( "Error sending mail\n" ); + wfDebug( "Unknown error sending mail\n" ); return Status::newFatal( 'php-mail-error-unknown' ); } else { return Status::newGood(); -- 2.20.1