r40846 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40845‎ | r40846 | r40847 >
Date:05:46, 15 September 2008
Author:tstarling
Status:old
Tags:
Comment:
Revert r40806 (never use RC). Use the $user parameter to Article::doEdit() instead of saving and restoring $wgUser. Requires MW r40845 or later. Tested with CheckUser, no more confusion observed than what you'd expect: the new user message is logged with the user's IP.
Modified paths:
  • /trunk/extensions/NewUserMessage/NewUserMessage.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/NewUserMessage/NewUserMessage.class.php
@@ -21,23 +21,20 @@
2222 $talk = $user->getTalkPage();
2323
2424 if (!$talk->exists()) {
25 - global $wgUser, $wgNewUserMinorEdit;
 25+ global $wgUser, $wgNewUserMinorEdit, $wgNewUserSuppressRC;
2626
2727 wfLoadExtensionMessages( 'NewUserMessage' );
2828
2929 $article = new Article($talk);
3030
31 - // Need to make the edit on the user talk page in another
32 - // user's context. Park the current user object and create
33 - // a user object for $editingUser. If that user does not
34 - // exist, create it.
35 - $parkedWgUser = $wgUser;
36 - $wgUser = User::newFromName( wfMsgForContent( 'newusermessage-editor' ) );
37 - if ( !$wgUser->isLoggedIn() ) {
38 - $wgUser->addToDatabase();
 31+ // Create a user object for the editing user and add it to the database
 32+ // if it's not there already
 33+ $editor = User::newFromName( wfMsgForContent( 'newusermessage-editor' ) );
 34+ if ( !$editor->isLoggedIn() ) {
 35+ $editor->addToDatabase();
3936 }
4037
41 - $flags = EDIT_NEW | EDIT_SUPPRESS_RC;
 38+ $flags = EDIT_NEW;
4239 $templateTitleText = wfMsg( 'newusermessage-template' );
4340 $templateTitle = Title::newFromText( $templateTitleText );
4441 if ( !$templateTitle ) {
@@ -48,6 +45,7 @@
4946 $templateTitleText = $templateTitle->getText();
5047 }
5148 if ($wgNewUserMinorEdit) $flags = $flags | EDIT_MINOR;
 49+ if ($wgNewUserSuppressRC) $flags = $flags | EDIT_SUPPRESS_RC;
5250
5351 $dbw = wfGetDB( DB_MASTER );
5452 $dbw->begin();
@@ -65,7 +63,7 @@
6664 }
6765 }
6866 try {
69 - $article->doEdit( $text, wfMsgForContent( 'newuseredit-summary' ), $flags );
 67+ $article->doEdit( $text, wfMsgForContent( 'newuseredit-summary' ), $flags, false, $editor );
7068 } catch ( DBQueryError $e ) {
7169 $good = false;
7270 }
@@ -79,7 +77,6 @@
8078 wfDebug( __METHOD__. ": the article has already been created despite !\$talk->exists()\n" );
8179 $dbw->rollback();
8280 }
83 - $wgUser = $parkedWgUser;
8481 }
8582 return true;
8683 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r40806Make NewUserMessage always use EDIT_SUPPRESS_RC, instead of making this an op...krimpet02:29, 14 September 2008
r40845Fix $user parameter to Article::doEdit(), which was broken for page creation ...tstarling05:34, 15 September 2008