r99942 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99941‎ | r99942 | r99943 >
Date:09:53, 16 October 2011
Author:ialex
Status:resolved (Comments)
Tags:
Comment:
* Do magic word parsing after parameter replacement in MediaWiki:Enotif_body and MediaWiki:Enotif_subject
* Fix link to Special:EmailUser in case $wgEnotifUseRealName was true and the user defined a real name, link was pointing to Special:EmailUser/Real_Name instead of Special:EmailUser/User_Name
* Simplified the code of EmailNotification::composeCommonMailtext()
Modified paths:
  • /trunk/phase3/includes/UserMailer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/UserMailer.php
@@ -557,18 +557,11 @@
558558
559559 $this->composed_common = true;
560560
561 - $summary = ( $this->summary == '' ) ? ' - ' : $this->summary;
562 - $medit = ( $this->minorEdit ) ? wfMsgForContent( 'minoredit' ) : '';
563 -
564561 # You as the WikiAdmin and Sysops can make use of plenty of
565562 # named variables when composing your notification emails while
566563 # simply editing the Meta pages
567564
568 - $subject = wfMsgForContent( 'enotif_subject' );
569 - $body = wfMsgForContent( 'enotif_body' );
570 - $from = ''; /* fail safe */
571 - $replyto = ''; /* fail safe */
572 - $keys = array();
 565+ $keys = array();
573566
574567 if ( $this->oldid ) {
575568 if ( $wgEnotifImpersonal ) {
@@ -588,60 +581,54 @@
589582 $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'created' );
590583 }
591584
592 - $body = strtr( $body, $keys );
593 - $pagetitle = $this->title->getPrefixedText();
594 - $keys['$PAGETITLE'] = $pagetitle;
595 - $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl();
 585+ $keys['$PAGETITLE'] = $this->title->getPrefixedText();
 586+ $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl();
 587+ $keys['$PAGEMINOREDIT'] = $this->minorEdit ? wfMsgForContent( 'minoredit' ) : '';
 588+ $keys['$PAGESUMMARY'] = $this->summary == '' ? ' - ' : $this->summary;
 589+ $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl( 'action=unwatch' );
596590
597 - $keys['$PAGEMINOREDIT'] = $medit;
598 - $keys['$PAGESUMMARY'] = $summary;
599 - $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl( 'action=unwatch' );
 591+ if ( $this->editor->isAnon() ) {
 592+ # real anon (user:xxx.xxx.xxx.xxx)
 593+ $keys['$PAGEEDITOR'] = wfMsgForContent( 'enotif_anon_editor', $this->editor->getName() );
 594+ $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' );
 595+ } else {
 596+ $keys['$PAGEEDITOR'] = $wgEnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName();
 597+ $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $this->editor->getName() );
 598+ $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalUrl();
 599+ }
600600
 601+ $keys['$PAGEEDITOR_WIKI'] = $this->editor->getUserPage()->getCanonicalUrl();
 602+
 603+ # Now build message's subject and body
 604+
 605+ $subject = wfMsgExt( 'enotif_subject', 'content' );
601606 $subject = strtr( $subject, $keys );
 607+ $this->subject = MessageCache::singleton()->transform( $subject, false, null, $this->title );
602608
 609+ $body = wfMsgExt( 'enotif_body', 'content' );
 610+ $body = strtr( $body, $keys );
 611+ $body = MessageCache::singleton()->transform( $body, false, null, $this->title );
 612+ $this->body = wordwrap( $body, 72 );
 613+
603614 # Reveal the page editor's address as REPLY-TO address only if
604615 # the user has not opted-out and the option is enabled at the
605616 # global configuration level.
606 - $editor = $this->editor;
607 - $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName();
608617 $adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
609 - $editorAddress = new MailAddress( $editor );
610618 if ( $wgEnotifRevealEditorAddress
611 - && ( $editor->getEmail() != '' )
612 - && $editor->getOption( 'enotifrevealaddr' ) ) {
 619+ && ( $this->editor->getEmail() != '' )
 620+ && $this->editor->getOption( 'enotifrevealaddr' ) )
 621+ {
 622+ $editorAddress = new MailAddress( $this->editor );
613623 if ( $wgEnotifFromEditor ) {
614 - $from = $editorAddress;
 624+ $this->from = $editorAddress;
615625 } else {
616 - $from = $adminAddress;
617 - $replyto = $editorAddress;
 626+ $this->from = $adminAddress;
 627+ $this->replyto = $editorAddress;
618628 }
619629 } else {
620 - $from = $adminAddress;
621 - $replyto = new MailAddress( $wgNoReplyAddress );
 630+ $this->from = $adminAddress;
 631+ $this->replyto = new MailAddress( $wgNoReplyAddress );
622632 }
623 -
624 - if ( $editor->isAnon() ) {
625 - # real anon (user:xxx.xxx.xxx.xxx)
626 - $utext = wfMsgForContent( 'enotif_anon_editor', $name );
627 - $subject = str_replace( '$PAGEEDITOR', $utext, $subject );
628 - $keys['$PAGEEDITOR'] = $utext;
629 - $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' );
630 - } else {
631 - $subject = str_replace( '$PAGEEDITOR', $name, $subject );
632 - $keys['$PAGEEDITOR'] = $name;
633 - $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $name );
634 - $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalUrl();
635 - }
636 - $userPage = $editor->getUserPage();
637 - $keys['$PAGEEDITOR_WIKI'] = $userPage->getCanonicalUrl();
638 - $body = strtr( $body, $keys );
639 - $body = wordwrap( $body, 72 );
640 -
641 - # now save this as the constant user-independent part of the message
642 - $this->from = $from;
643 - $this->replyto = $replyto;
644 - $this->subject = $subject;
645 - $this->body = $body;
646633 }
647634
648635 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r107920Per request of Reedy, MFT r99942 and r99950ialex18:38, 3 January 2012
r107948Merge r107920, so essentially merging r99942, r99950reedy22:06, 3 January 2012
r113407* (bug 35019) Fix for rr99942: edit summaries are no longer transformed in no...ialex21:39, 8 March 2012

Comments

#Comment by Nikerabbit (talk | contribs)   10:45, 16 October 2011

I think you are pretty close to fixing bug 22769 and probably already fixed bug 29170.

#Comment by MarkAHershberger (talk | contribs)   03:31, 14 December 2011

Also bug 32985

#Comment by MaxSem (talk | contribs)   19:19, 8 March 2012

Looks like it causes bug 35019: Edit summary shouldn't be parsed as wikitext into html in e-mail notifications

#Comment by IAlex (talk | contribs)   21:40, 8 March 2012

Fixed in r113407.

Status & tagging log