r113352 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113351‎ | r113352 | r113353 >
Date:09:46, 8 March 2012
Author:krinkle
Status:ok
Tags:
Comment:
[NewUserMessage] Don't prepend 2 empty lines before the Welcome template
* First line, meant to offset from potentially pre-existent content. Aside from the fact that the caller of this function only runs if !$talk->exists(), it could potentially exist later in a race condition (I've never seen this happen, but the code is already checking for that case where it prepends getRawText()), moved the first newline to there.
* Second line, meant to offset from the ==subject==, moved to within the if statement

* Fixes:
-- (bug 35058) [Regression] Don't prepend 2 empty lines before the Welcome template
Modified paths:
  • /trunk/extensions/NewUserMessage/NewUserMessage.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/NewUserMessage/NewUserMessage.class.php
@@ -153,6 +153,7 @@
154154 static function createNewUserMessage( $user ) {
155155 $talk = $user->getTalkPage();
156156
 157+ // Only leave message if user doesn't have a talk page yet
157158 if ( !$talk->exists() ) {
158159 $article = new Article( $talk );
159160 $subject = self::fetchSubject();
@@ -223,7 +224,7 @@
224225 $flags = $article->checkFlags( $flags );
225226
226227 if ( $flags & EDIT_UPDATE ) {
227 - $text = $article->getRawText() . $text;
 228+ $text = $article->getRawText() . "\n" . $text;
228229 }
229230
230231 $dbw = wfGetDB( DB_MASTER );
@@ -255,13 +256,13 @@
256257 * @param $signature String the signature, if provided.
257258 */
258259 static protected function formatUserMessage( $subject, $text, $signature ) {
259 - $contents = "\n";
 260+ $contents = "";
260261 $signature = empty( $signature ) ? "~~~~" : "{$signature} ~~~~~";
261262
262263 if ( $subject ) {
263 - $contents .= "== $subject ==\n";
 264+ $contents .= "== $subject ==\n\n";
264265 }
265 - $contents .= "\n$text\n\n-- $signature\n";
 266+ $contents .= "$text\n\n-- $signature\n";
266267
267268 return $contents;
268269 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r113940MFT r112586, r112930, r113352, r113926reedy17:51, 15 March 2012
r114017MFT r112586, r112926, r112930, r113352reedy15:24, 16 March 2012

Status & tagging log