r56696 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56695‎ | r56696 | r56697 >
Date:10:57, 21 September 2009
Author:happy-melon
Status:reverted
Tags:
Comment:
Follow-up to r56684; fix newuser log.
Modified paths:
  • /trunk/extensions/OpenID/SpecialOpenIDLogin.body.php (modified) (history)
  • /trunk/phase3/includes/Login.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -3492,23 +3492,32 @@
34933493
34943494 /**
34953495 * Add a newuser log entry for this user
 3496+ * @param $creator User who
34963497 * @param $byEmail Boolean: account made by email?
34973498 */
3498 - public function addNewUserLogEntry( $byEmail = false ) {
 3499+ public function addNewUserLogEntry( $creator, $byEmail = false ) {
34993500 global $wgUser, $wgContLang, $wgNewUserLog;
35003501 if( empty($wgNewUserLog) ) {
35013502 return true; // disabled
35023503 }
35033504 $talk = $wgContLang->getFormattedNsText( NS_TALK );
3504 - if( $this->getName() == $wgUser->getName() ) {
 3505+ if( $creator != $wgUser ) {
35053506 $action = 'create';
35063507 $message = '';
35073508 } else {
35083509 $action = 'create2';
3509 - $message = $byEmail ? wfMsgForContent( 'newuserlog-byemail' ) : '';
 3510+ $message = $byEmail
 3511+ ? wfMsgForContent( 'newuserlog-byemail' )
 3512+ : '';
35103513 }
35113514 $log = new LogPage( 'newusers' );
3512 - $log->addEntry( $action, $this->getUserPage(), $message, array( $this->getId() ) );
 3515+ $log->addEntry(
 3516+ $action,
 3517+ $this->getUserPage(),
 3518+ $message,
 3519+ array( $this->getId() ),
 3520+ $creator
 3521+ );
35133522 return true;
35143523 }
35153524
Index: trunk/phase3/includes/Login.php
@@ -298,11 +298,11 @@
299299 * Db errors etc).
300300 */
301301 protected function initUser( $autocreate=false, $byEmail=false ) {
302 - global $wgAuth;
 302+ global $wgAuth, $wgUser;
303303
304304 $fields = array(
305305 'name' => $this->mName,
306 - 'password' => $byEmail ? null : $this->mPassword,
 306+ 'password' => $byEmail ? null : User::crypt( $this->mPassword ),
307307 'email' => $this->mEmail,
308308 'options' => array(
309309 'rememberpassword' => $this->mRemember ? 1 : 0,
@@ -332,8 +332,11 @@
333333 $ssUpdate->doUpdate();
334334 if( $autocreate )
335335 $this->mUser->addNewUserLogEntryAutoCreate();
 336+ elseif( $wgUser->isAnon() )
 337+ # Avoid spamming IP addresses all over the newuser log
 338+ $this->mUser->addNewUserLogEntry( $this->mUser, $byEmail );
336339 else
337 - $this->mUser->addNewUserLogEntry( $byEmail );
 340+ $this->mUser->addNewUserLogEntry( $wgUser, $byEmail );
338341
339342 # Run hooks
340343 wfRunHooks( 'AddNewAccount', array( $this->mUser ) );
Index: trunk/extensions/OpenID/SpecialOpenIDLogin.body.php
@@ -493,6 +493,7 @@
494494 $wgOut->returnToMain( false, $this->returnTo() );
495495 }
496496
 497+ # FIXME: this should probably use a Login method
497498 function createUser( $openid, $sreg, $name ) {
498499 global $wgAuth;
499500
@@ -504,7 +505,7 @@
505506 }
506507
507508 $user->addToDatabase();
508 - $user->addNewUserLogEntry();
 509+ $user->addNewUserLogEntry( $user );
509510
510511 if ( !$user->getId() ) {
511512 wfDebug( "OpenID: Error adding new user.\n" );

Follow-up revisions

RevisionCommit summaryAuthorDate
r56937Revert broken rewrite of login system; totally broken....brion00:49, 26 September 2009
r56963Revert r56696. Even though mentioned in r56937 ("Revert broken rewrite of log...siebrand23:47, 26 September 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r56684Merge in Login rewrite, second time lucky.happy-melon20:28, 20 September 2009

Status & tagging log