From 9a4677d35d342020aedbea7bce4e70690fe4aa77 Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Mon, 21 Sep 2009 10:57:06 +0000 Subject: [PATCH] Follow-up to r56684; fix newuser log. --- includes/Login.php | 9 ++++++--- includes/User.php | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/includes/Login.php b/includes/Login.php index a2d8879f6f..c30858c0cf 100644 --- a/includes/Login.php +++ b/includes/Login.php @@ -298,11 +298,11 @@ class Login { * Db errors etc). */ protected function initUser( $autocreate=false, $byEmail=false ) { - global $wgAuth; + global $wgAuth, $wgUser; $fields = array( 'name' => $this->mName, - 'password' => $byEmail ? null : $this->mPassword, + 'password' => $byEmail ? null : User::crypt( $this->mPassword ), 'email' => $this->mEmail, 'options' => array( 'rememberpassword' => $this->mRemember ? 1 : 0, @@ -332,8 +332,11 @@ class Login { $ssUpdate->doUpdate(); if( $autocreate ) $this->mUser->addNewUserLogEntryAutoCreate(); + elseif( $wgUser->isAnon() ) + # Avoid spamming IP addresses all over the newuser log + $this->mUser->addNewUserLogEntry( $this->mUser, $byEmail ); else - $this->mUser->addNewUserLogEntry( $byEmail ); + $this->mUser->addNewUserLogEntry( $wgUser, $byEmail ); # Run hooks wfRunHooks( 'AddNewAccount', array( $this->mUser ) ); diff --git a/includes/User.php b/includes/User.php index eecaccfc50..f599d7647c 100644 --- a/includes/User.php +++ b/includes/User.php @@ -3492,23 +3492,32 @@ class User { /** * Add a newuser log entry for this user + * @param $creator User who * @param $byEmail Boolean: account made by email? */ - public function addNewUserLogEntry( $byEmail = false ) { + public function addNewUserLogEntry( $creator, $byEmail = false ) { global $wgUser, $wgContLang, $wgNewUserLog; if( empty($wgNewUserLog) ) { return true; // disabled } $talk = $wgContLang->getFormattedNsText( NS_TALK ); - if( $this->getName() == $wgUser->getName() ) { + if( $creator != $wgUser ) { $action = 'create'; $message = ''; } else { $action = 'create2'; - $message = $byEmail ? wfMsgForContent( 'newuserlog-byemail' ) : ''; + $message = $byEmail + ? wfMsgForContent( 'newuserlog-byemail' ) + : ''; } $log = new LogPage( 'newusers' ); - $log->addEntry( $action, $this->getUserPage(), $message, array( $this->getId() ) ); + $log->addEntry( + $action, + $this->getUserPage(), + $message, + array( $this->getId() ), + $creator + ); return true; } -- 2.20.1