r93410 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93409‎ | r93410 | r93411 >
Date:19:03, 28 July 2011
Author:mah
Status:ok
Tags:
Comment:
* followup r93397 — missing $dest
* Otherwise clean up $dest usage
* Clean up Debug messages
Modified paths:
  • /trunk/phase3/includes/UserMailer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/UserMailer.php
@@ -143,11 +143,22 @@
144144 $headers['From'] = $from->toString();
145145 $headers['Return-Path'] = $from->toString();
146146
 147+ $dest = array();
 148+ if ( is_array( $to ) ) {
 149+ foreach ( $to as $u ) {
 150+ if ( $u->address ) {
 151+ $dest[] = $u->address;
 152+ }
 153+ }
 154+ } else if( $to->address ) {
 155+ $dest[] = $to->address;
 156+ }
 157+
147158 if ( $wgEnotifImpersonal ) {
148159 $headers['To'] = 'undisclosed-recipients:;';
149160 }
150161 else {
151 - $headers['To'] = implode( ", ", (array )$dest );
 162+ $headers['To'] = implode( ", ", $dest );
152163 }
153164
154165 if ( $replyto ) {
@@ -180,15 +191,6 @@
181192 $msgid .= '.' . posix_getpid();
182193 }
183194
184 - if ( is_array( $to ) ) {
185 - $dest = array();
186 - foreach ( $to as $u ) {
187 - $dest[] = $u->address;
188 - }
189 - } else {
190 - $dest = $to->address;
191 - }
192 -
193195 wfSuppressWarnings();
194196
195197 // Create the mail object using the Mail::factory method
@@ -199,8 +201,8 @@
200202 return Status::newFatal( 'pear-mail-error', $mail_object->getMessage() );
201203 }
202204
203 - wfDebug( "Sending mail via PEAR::Mail to $dest\n" );
204 - $chunks = array_chunk( (array)$dest, $wgEnotifMaxRecips );
 205+ wfDebug( "Sending mail via PEAR::Mail\n" );
 206+ $chunks = array_chunk( $dest, $wgEnotifMaxRecips );
205207 foreach ( $chunks as $chunk ) {
206208 $status = self::sendWithPear( $mail_object, $chunk, $headers, $body );
207209 if ( !$status->isOK() ) {
@@ -244,7 +246,7 @@
245247 return Status::newFatal( 'php-mail-error', self::$mErrorString );
246248 } elseif ( ! $sent ) {
247249 // mail function only tells if there's an error
248 - wfDebug( "Error sending mail\n" );
 250+ wfDebug( "Unknown error sending mail\n" );
249251 return Status::newFatal( 'php-mail-error-unknown' );
250252 } else {
251253 return Status::newGood();

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93397Reduce mail header differences by moving all the header creation code...mah16:56, 28 July 2011

Status & tagging log