Fixes Bug#17866
authorMark A. Hershberger <mah@users.mediawiki.org>
Thu, 7 Jul 2011 19:11:25 +0000 (19:11 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Thu, 7 Jul 2011 19:11:25 +0000 (19:11 +0000)
Minimal check that we have more than an empty string before sending and email. NikeRabbit asked me about LQT sending email to users w/o email addresses and this looked like one good place to add a check.

includes/UserMailer.php

index 0a7dc7f..e2fd7e9 100644 (file)
@@ -55,16 +55,18 @@ class MailAddress {
                # PHP's mail() implementation under Windows is somewhat shite, and
                # can't handle "Joe Bloggs <joe@bloggs.com>" format email addresses,
                # so don't bother generating them
-               if ( $this->name != '' && !wfIsWindows() ) {
-                       global $wgEnotifUseRealName;
-                       $name = ( $wgEnotifUseRealName && $this->realName ) ? $this->realName : $this->name;
-                       $quoted = UserMailer::quotedPrintable( $name );
-                       if ( strpos( $quoted, '.' ) !== false || strpos( $quoted, ',' ) !== false ) {
-                               $quoted = '"' . $quoted . '"';
+               if ( $this->address ) {
+                       if ( $this->name != '' && !wfIsWindows() ) {
+                               global $wgEnotifUseRealName;
+                               $name = ( $wgEnotifUseRealName && $this->realName ) ? $this->realName : $this->name;
+                               $quoted = UserMailer::quotedPrintable( $name );
+                               if ( strpos( $quoted, '.' ) !== false || strpos( $quoted, ',' ) !== false ) {
+                                       $quoted = '"' . $quoted . '"';
+                               }
+                               return "$quoted <{$this->address}>";
+                       } else {
+                               return $this->address;
                        }
-                       return "$quoted <{$this->address}>";
-               } else {
-                       return $this->address;
                }
        }