r107948 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107947‎ | r107948 | r107949 >
Date:22:06, 3 January 2012
Author:reedy
Status:ok
Tags:
Comment:
Merge r107920, so essentially merging r99942, r99950
Modified paths:
  • /branches/wmf/1.18wmf1 (modified) (history)
  • /branches/wmf/1.18wmf1/includes (modified) (history)
  • /branches/wmf/1.18wmf1/includes/UserMailer.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/includes/UserMailer.php
@@ -119,22 +119,14 @@
120120 * @return Status object
121121 */
122122 public static function send( $to, $from, $subject, $body, $replyto = null, $contentType = 'text/plain; charset=UTF-8') {
123 - global $wgSMTP, $wgEnotifImpersonal;
124 - global $wgEnotifMaxRecips, $wgAdditionalMailParams;
 123+ global $wgSMTP, $wgEnotifMaxRecips, $wgAdditionalMailParams;
125124
126 - if ( is_array( $to ) ) {
127 - $emails = '';
128 - // This wouldn't be necessary if implode() worked on arrays of
129 - // objects using __toString(). http://bugs.php.net/bug.php?id=36612
130 - foreach ( $to as $t ) {
131 - $emails .= $t->toString() . ",";
132 - }
133 - $emails = rtrim( $emails, ',' );
134 - wfDebug( __METHOD__ . ': sending mail to ' . $emails . "\n" );
135 - } else {
136 - wfDebug( __METHOD__ . ': sending mail to ' . implode( ',', array( $to->toString() ) ) . "\n" );
 125+ if ( !is_array( $to ) ) {
 126+ $to = array( $to );
137127 }
138128
 129+ wfDebug( __METHOD__ . ': sending mail to ' . implode( ', ', $to ) . "\n" );
 130+
139131 if ( is_array( $wgSMTP ) ) {
140132 if ( function_exists( 'stream_resolve_include_path' ) ) {
141133 $found = stream_resolve_include_path( 'Mail.php' );
@@ -161,13 +153,13 @@
162154 }
163155
164156 $headers['From'] = $from->toString();
165 - $headers['Return-Path'] = $from->toString();
 157+ $headers['Return-Path'] = $from->address;
166158
167 - if ( $wgEnotifImpersonal ) {
 159+ if ( count( $to ) > 1 ) {
168160 $headers['To'] = 'undisclosed-recipients:;';
169161 }
170162 else {
171 - $headers['To'] = implode( ", ", (array )$dest );
 163+ $headers['To'] = $to[0]->toString();
172164 }
173165
174166 if ( $replyto ) {
@@ -177,7 +169,7 @@
178170 $headers['Date'] = date( 'r' );
179171 $headers['MIME-Version'] = '1.0';
180172 $headers['Content-type'] = ( is_null( $contentType ) ?
181 - 'text/plain; charset=UTF-8' : $contentType );
 173+ 'text/plain; charset=UTF-8' : $contentType );
182174 $headers['Content-transfer-encoding'] = '8bit';
183175 // @todo FIXME
184176 $headers['Message-ID'] = "<$msgid@" . $wgSMTP['IDHost'] . '>';
@@ -532,18 +524,11 @@
533525
534526 $this->composed_common = true;
535527
536 - $summary = ( $this->summary == '' ) ? ' - ' : $this->summary;
537 - $medit = ( $this->minorEdit ) ? wfMsgForContent( 'minoredit' ) : '';
538 -
539528 # You as the WikiAdmin and Sysops can make use of plenty of
540529 # named variables when composing your notification emails while
541530 # simply editing the Meta pages
542531
543 - $subject = wfMsgForContent( 'enotif_subject' );
544 - $body = wfMsgForContent( 'enotif_body' );
545 - $from = ''; /* fail safe */
546 - $replyto = ''; /* fail safe */
547 - $keys = array();
 532+ $keys = array();
548533
549534 if ( $this->oldid ) {
550535 $difflink = $this->title->getCanonicalUrl( 'diff=0&oldid=' . $this->oldid );
@@ -557,69 +542,54 @@
558543 $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'created' );
559544 }
560545
561 - if ( $wgEnotifImpersonal && $this->oldid ) {
562 - /**
563 - * For impersonal mail, show a diff link to the last
564 - * revision.
565 - */
566 - $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastdiff',
567 - $this->title->getCanonicalUrl( "oldid={$this->oldid}&diff=next" ) );
 546+ $keys['$PAGETITLE'] = $this->title->getPrefixedText();
 547+ $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl();
 548+ $keys['$PAGEMINOREDIT'] = $this->minorEdit ? wfMsgForContent( 'minoredit' ) : '';
 549+ $keys['$PAGESUMMARY'] = $this->summary == '' ? ' - ' : $this->summary;
 550+ $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl( 'action=unwatch' );
 551+
 552+ if ( $this->editor->isAnon() ) {
 553+ # real anon (user:xxx.xxx.xxx.xxx)
 554+ $keys['$PAGEEDITOR'] = wfMsgForContent( 'enotif_anon_editor', $this->editor->getName() );
 555+ $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' );
 556+ } else {
 557+ $keys['$PAGEEDITOR'] = $wgEnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName();
 558+ $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $this->editor->getName() );
 559+ $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalUrl();
568560 }
569561
570 - $body = strtr( $body, $keys );
571 - $pagetitle = $this->title->getPrefixedText();
572 - $keys['$PAGETITLE'] = $pagetitle;
573 - $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl();
 562+ $keys['$PAGEEDITOR_WIKI'] = $this->editor->getUserPage()->getCanonicalUrl();
574563
575 - $keys['$PAGEMINOREDIT'] = $medit;
576 - $keys['$PAGESUMMARY'] = $summary;
577 - $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl( 'action=unwatch' );
 564+ # Now build message's subject and body
578565
 566+ $subject = wfMsgExt( 'enotif_subject', 'content' );
579567 $subject = strtr( $subject, $keys );
 568+ $this->subject = MessageCache::singleton()->transform( $subject, false, null, $this->title );
580569
 570+ $body = wfMsgExt( 'enotif_body', 'content' );
 571+ $body = strtr( $body, $keys );
 572+ $body = MessageCache::singleton()->transform( $body, false, null, $this->title );
 573+ $this->body = wordwrap( $body, 72 );
 574+
581575 # Reveal the page editor's address as REPLY-TO address only if
582576 # the user has not opted-out and the option is enabled at the
583577 # global configuration level.
584 - $editor = $this->editor;
585 - $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName();
586578 $adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
587 - $editorAddress = new MailAddress( $editor );
588579 if ( $wgEnotifRevealEditorAddress
589 - && ( $editor->getEmail() != '' )
590 - && $editor->getOption( 'enotifrevealaddr' ) ) {
 580+ && ( $this->editor->getEmail() != '' )
 581+ && $this->editor->getOption( 'enotifrevealaddr' ) )
 582+ {
 583+ $editorAddress = new MailAddress( $this->editor );
591584 if ( $wgEnotifFromEditor ) {
592 - $from = $editorAddress;
 585+ $this->from = $editorAddress;
593586 } else {
594 - $from = $adminAddress;
595 - $replyto = $editorAddress;
 587+ $this->from = $adminAddress;
 588+ $this->replyto = $editorAddress;
596589 }
597590 } else {
598 - $from = $adminAddress;
599 - $replyto = new MailAddress( $wgNoReplyAddress );
 591+ $this->from = $adminAddress;
 592+ $this->replyto = new MailAddress( $wgNoReplyAddress );
600593 }
601 -
602 - if ( $editor->isAnon() ) {
603 - # real anon (user:xxx.xxx.xxx.xxx)
604 - $utext = wfMsgForContent( 'enotif_anon_editor', $name );
605 - $subject = str_replace( '$PAGEEDITOR', $utext, $subject );
606 - $keys['$PAGEEDITOR'] = $utext;
607 - $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' );
608 - } else {
609 - $subject = str_replace( '$PAGEEDITOR', $name, $subject );
610 - $keys['$PAGEEDITOR'] = $name;
611 - $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $name );
612 - $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalUrl();
613 - }
614 - $userPage = $editor->getUserPage();
615 - $keys['$PAGEEDITOR_WIKI'] = $userPage->getCanonicalUrl();
616 - $body = strtr( $body, $keys );
617 - $body = wordwrap( $body, 72 );
618 -
619 - # now save this as the constant user-independent part of the message
620 - $this->from = $from;
621 - $this->replyto = $replyto;
622 - $this->subject = $subject;
623 - $this->body = $body;
624594 }
625595
626596 /**
Property changes on: branches/wmf/1.18wmf1/includes
___________________________________________________________________
Modified: svn:mergeinfo
627597 Merged /branches/REL1_18/phase3/includes:r107920
Property changes on: branches/wmf/1.18wmf1
___________________________________________________________________
Modified: svn:mergeinfo
628598 Merged /branches/REL1_18/phase3:r107920

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99942* Do magic word parsing after parameter replacement in MediaWiki:Enotif_body ...ialex09:53, 16 October 2011
r99950* Send "undisclosed-recipients" in "To" header when sending the mail to more ...ialex12:39, 16 October 2011
r107920Per request of Reedy, MFT r99942 and r99950ialex18:38, 3 January 2012

Status & tagging log