Umherirrender has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/225652

Change subject: Avoid ip fallback in User::getName
......................................................................

Avoid ip fallback in User::getName

A user was seeing his own ip address in recent changes for new creation
log instead of the new user name. The ip fallback in User::getName is a
possible cause for that.

Set the ip as name for anon in loadDefaults to have the name set, when
User::getName is called for anon users. In case there was really no user
loaded from the database due to slave lags, throw an exception to avoid
returning false, which can give errors in the further processing.

Change-Id: I97d4558a6b9afa5a7a8683cbcb931e8cce0ed341
---
M includes/User.php
1 file changed, 2 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/52/225652/1

diff --git a/includes/User.php b/includes/User.php
index d627a6d..2e6d36d 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -1044,7 +1044,7 @@
                $passwordFactory = self::getPasswordFactory();
 
                $this->mId = 0;
-               $this->mName = $name;
+               $this->mName = $name ?: IP::sanitizeIP( 
$this->getRequest()->getIP() );
                $this->mRealName = '';
                $this->mPassword = $passwordFactory->newFromCiphertext( null );
                $this->mNewpassword = $passwordFactory->newFromCiphertext( null 
);
@@ -2044,8 +2044,7 @@
                } else {
                        $this->load();
                        if ( $this->mName === false ) {
-                               // Clean up IPs
-                               $this->mName = IP::sanitizeIP( 
$this->getRequest()->getIP() );
+                               throw new Exception( 'Could not find user name 
for ' . $this->mId . ' in ' . __METHOD__ );
                        }
                        return $this->mName;
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/225652
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I97d4558a6b9afa5a7a8683cbcb931e8cce0ed341
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to