X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fmail%2FMailAddress.php;h=63a114d2a965d71ddfaf2b6977ef990b5d95bdb5;hp=b9d94143d00f97a2908ba2ffbc5b80df66333fdb;hb=da9c742af04791e52f0e4552d3a77a55b558f088;hpb=4f4a620f8e5993f2c1ae8f2afbb999e42ee77471 diff --git a/includes/mail/MailAddress.php b/includes/mail/MailAddress.php index b9d94143d0..63a114d2a9 100644 --- a/includes/mail/MailAddress.php +++ b/includes/mail/MailAddress.php @@ -46,22 +46,14 @@ class MailAddress { public $address; /** - * @param string $address String with an email address, or a User object - * @param string $name Human-readable name if a string address is given - * @param string $realName Human-readable real name if a string address is given + * @param string $address String with an email address + * @param string|null $name Human-readable name if a string address is given + * @param string|null $realName Human-readable real name if a string address is given */ - function __construct( $address, $name = null, $realName = null ) { - if ( is_object( $address ) && $address instanceof User ) { - // Old calling format, now deprecated - wfDeprecated( __METHOD__ . ' with a User object', '1.24' ); - $this->address = $address->getEmail(); - $this->name = $address->getName(); - $this->realName = $address->getRealName(); - } else { - $this->address = strval( $address ); - $this->name = strval( $name ); - $this->realName = strval( $realName ); - } + public function __construct( $address, $name = null, $realName = null ) { + $this->address = strval( $address ); + $this->name = strval( $name ); + $this->realName = strval( $realName ); } /** @@ -80,25 +72,26 @@ class MailAddress { * @return string */ function toString() { + if ( !$this->address ) { + return ''; + } + # PHP's mail() implementation under Windows is somewhat shite, and # can't handle "Joe Bloggs " format email addresses, # so don't bother generating them - if ( $this->address ) { - if ( $this->name != '' && !wfIsWindows() ) { - global $wgEnotifUseRealName; - $name = ( $wgEnotifUseRealName && $this->realName !== '' ) ? $this->realName : $this->name; - $quoted = UserMailer::quotedPrintable( $name ); - // Must only be quoted if string does not use =? encoding (T191931) - if ( $quoted === $name ) { - $quoted = '"' . addslashes( $quoted ) . '"'; - } - return "$quoted <{$this->address}>"; - } else { - return $this->address; - } - } else { - return ""; + if ( $this->name === '' || wfIsWindows() ) { + return $this->address; } + + global $wgEnotifUseRealName; + $name = ( $wgEnotifUseRealName && $this->realName !== '' ) ? $this->realName : $this->name; + $quoted = UserMailer::quotedPrintable( $name ); + // Must only be quoted if string does not use =? encoding (T191931) + if ( $quoted === $name ) { + $quoted = '"' . addslashes( $quoted ) . '"'; + } + + return "$quoted <{$this->address}>"; } function __toString() {