r93412 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93411‎ | r93412 | r93413 >
Date:19:15, 28 July 2011
Author:mah
Status:ok (Comments)
Tags:
Comment:
further sanity checks for sending email … bomb out if we aren't given
any user with an email address.
Modified paths:
  • /trunk/phase3/includes/UserMailer.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/UserMailer.php
@@ -67,6 +67,8 @@
6868 } else {
6969 return $this->address;
7070 }
 71+ } else {
 72+ return "";
7173 }
7274 }
7375
@@ -153,6 +155,9 @@
154156 } else if( $to->address ) {
155157 $dest[] = $to->address;
156158 }
 159+ if ( count( $dest ) == 0 ) {
 160+ return Status::newFatal( 'user-mail-no-addy' );
 161+ }
157162
158163 if ( $wgEnotifImpersonal ) {
159164 $headers['To'] = 'undisclosed-recipients:;';
@@ -231,12 +236,9 @@
232237 ini_set( 'html_errors', '0' );
233238 set_error_handler( 'UserMailer::errorHandler' );
234239
235 - if ( !is_array( $to ) ) {
236 - $to = array( $to );
 240+ foreach ( $dest as $recip ) {
 241+ $sent = mail( $recip, self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
237242 }
238 - foreach ( $to as $recip ) {
239 - $sent = mail( $recip->toString(), self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
240 - }
241243
242244 restore_error_handler();
243245 ini_set( 'html_errors', $html_errors );
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1146,6 +1146,7 @@
11471147 'pear-mail-error' => '$1', # do not translate or duplicate this message to other languages
11481148 'php-mail-error' => '$1', # do not translate or duplicate this message to other languages
11491149 'php-mail-error-unknown' => "Unknown error in PHP's mail() function",
 1150+'user-mail-no-addy' => "Tried to send email without an email address",
11501151
11511152 # Change password dialog
11521153 'resetpass' => 'Change password',

Follow-up revisions

RevisionCommit summaryAuthorDate
r93419Followup r93412: Register new message key in maintenance file...raymond19:46, 28 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91668Fixes Bug#17866...mah19:11, 7 July 2011

Comments

#Comment by Bawolff (talk | contribs)   04:06, 27 January 2012

Tagging 1.18. (I believe) fixes an issue in 1.18 where if you set $wgUsersNotifiedOnAllChanges = array( 'non-existing user' ); then a fatal error happens on page save.

Status & tagging log