Follow-up to r56684; fix newuser log.
authorHappy-melon <happy-melon@users.mediawiki.org>
Mon, 21 Sep 2009 10:57:06 +0000 (10:57 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Mon, 21 Sep 2009 10:57:06 +0000 (10:57 +0000)
includes/Login.php
includes/User.php

index a2d8879..c30858c 100644 (file)
@@ -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 ) );
index eecaccf..f599d76 100644 (file)
@@ -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;
        }