r82032 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82031‎ | r82032 | r82033 >
Date:21:02, 12 February 2011
Author:demon
Status:ok
Tags:
Comment:
MFT r81966, r81969 NewUserMessage fixes
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/NewUserMessage (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/NewUserMessage/NewUserMessage.class.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/NewUserMessage/NewUserMessage.i18n.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/NewUserMessage/NewUserMessage.i18n.php
@@ -15,6 +15,7 @@
1616 $messages['en'] = array(
1717 'newusermessage-desc' => "Adds a message to newly created user's talk pages",
1818 'newuseredit-summary' => 'Adding [[{{int:newusermessage-template}}|welcome message]] to new user\'s talk page',
 19+ 'newusermessage-template' => 'Template:Welcome', # The title of the message template
1920 'newusermessage-template-subject' => 'Template:Welcome-subject', # Always substituted. Used if LiquidThreads is enabled in the User_talk namespace. Do not translate or duplicate this message to other languages
2021 'newusermessage-template-body' => 'Template:Welcome-body', # Used if LiquidThreads is enabled in the User_talk namespace. Do not translate or duplicate this message to other languages
2122 'newusermessage-editor' => 'New user message', # The username used for the edit
Index: branches/wmf/1.17wmf1/extensions/NewUserMessage/NewUserMessage.class.php
@@ -83,7 +83,12 @@
8484 * @returns String
8585 */
8686 static function fetchText() {
87 - return self::fetchTemplateIfExists( wfMsg( 'newusermessage-template-body' ) );
 87+ $text = self::fetchTemplateIfExists( wfMsg( 'newusermessage-template-body' ) );
 88+ // Fall back if necessary to the old template
 89+ if ( !$text ) {
 90+ $text = self::fetchTemplateIfExists( wfMsg( 'newusermessage-template' ) );
 91+ }
 92+ return $text;
8893 }
8994
9095 /**
@@ -148,11 +153,17 @@
149154 $editor = self::fetchEditor();
150155 $flags = self::fetchFlags();
151156
152 - $subject = self::substString( $subject, $user, $editor, $talk, "preparse" );
153 - $text = self::substString( $text, $user, $editor, $talk );
 157+ if ( $subject ) {
 158+ $subject = self::substString( $subject, $user, $editor, $talk, "preparse" );
 159+ }
 160+ if ( $text ) {
 161+ $text = self::substString( $text, $user, $editor, $talk );
 162+ }
154163
155 - return self::leaveUserMessage( $user, $article, $subject, $text,
 164+ self::leaveUserMessage( $user, $article, $subject, $text,
156165 $signature, $editSummary, $editor, $flags );
 166+
 167+ return true;
157168 }
158169 }
159170
@@ -195,7 +206,6 @@
196207 */
197208 public static function leaveUserMessage( $user, $article, $subject, $text, $signature,
198209 $summary, $editor, $flags ) {
199 -
200210 $text = self::formatUserMessage( $subject, $text, $signature );
201211 $flags = $article->checkFlags( $flags );
202212
@@ -232,9 +242,14 @@
233243 * @param $signature String the signature, if provided.
234244 */
235245 static protected function formatUserMessage( $subject, $text, $signature ) {
236 - $signature = empty($signature) ? "~~~~~" : "{$signature} ~~~~~";
237 - $text = "\n== $subject ==\n\n$text\n\n-- $signature";
 246+ $contents = "\n";
 247+ $signature = empty( $signature ) ? "~~~~~" : "{$signature} ~~~~~";
 248+
 249+ if ( $subject ) {
 250+ $contents .= "== $subject ==\n";
 251+ }
 252+ $contents .= "\n$text\n\n-- $signature\n";
238253
239 - return $text;
 254+ return $contents;
240255 }
241256 }
Property changes on: branches/wmf/1.17wmf1/extensions/NewUserMessage
___________________________________________________________________
Added: svn:mergeinfo
242257 Merged /branches/sqlite/extensions/NewUserMessage:r58211-58321
243258 Merged /trunk/phase3/extensions/NewUserMessage:r79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,81833
244259 Merged /branches/new-installer/phase3/extensions/NewUserMessage:r43664-66004
245260 Merged /branches/wmf-deployment/extensions/NewUserMessage:r60970
246261 Merged /branches/REL1_15/phase3/extensions/NewUserMessage:r51646
247262 Merged /branches/wmf/1.16wmf4/extensions/NewUserMessage:r67177,69199,76243,77266
248263 Merged /trunk/extensions/NewUserMessage:r81966,81969

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81966Fixes for NewUserMessage:...btongminh14:46, 11 February 2011
r81969Don't return the return value of leaveUserMessage, as there is no reason to s...btongminh15:00, 11 February 2011

Status & tagging log