MediaWiki Bridge

Duplicate entry on second login - MediaWiki Bridge

Duplicate entry on second login

by monotek » Tue Feb 21, 2012 2:17 pm

I use Mediawiki 1.18.1 and PhPBB 3.0.10.

Login throws error on secon login:

Code: Select all

A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See: http://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script
Query: UPDATE `user` SET user_name = 'tester',user_password = '',user_newpassword = '',user_newpass_time = NULL,user_real_name = '',user_email = '[email protected]',user_email_authenticated = NULL,user_options = '',user_touched = '20120221141408',user_token = 'fdfdfdfdfdfdfdfdfdfdfdfdfdfdf',user_email_token = '',user_email_token_expires = NULL WHERE user_id = '234'
Function: User::saveSettings
Error: 1062 Duplicate entry 'tester' for key 'user_name' (localhost)


First login worked. Third and more login works again.

In the user table i have 2 entries for this user now:

user_name = 'tester'
user_name = 'Tester'

Any hints?
monotek
Registered User
Posts: 51
Joined: Mon Jan 29, 2007 4:40 pm
Contact:

Re: Duplicate entry on second login

by mandilorian » Wed Aug 22, 2012 12:56 am

I have the same issue, couldn't figure it out either. Did you ever solve this?

I've been trying to do the Mediawiki-Phpbb single login extension instead, but I'm not sure it'll work.
mandilorian
Registered User
Posts: 14
Joined: Wed Aug 08, 2012 11:13 pm
Contact:

Re: Duplicate entry on second login

by Chappos » Wed Dec 12, 2012 8:36 am

Same here. Any Solution yet?
Chappos
Registered User
Posts: 1
Joined: Wed Dec 12, 2012 8:32 am
Contact:

Re: Duplicate entry on second login

by maxslug » Tue Jun 04, 2013 6:48 pm

I think I found the bug and have a fix for it :

This function :

Code: Select all

        public function initUser(&$user, $autocreate = true)
        {
                $this->fillUserData(false, $user->mName);
                $user->mName           = $this->userdata['username'];
                $user->mEmail           = $this->userdata['user_email'];
        }


Should be changed to :

Code: Select all

        public function initUser(&$user, $autocreate = true)
        {
                global $wgContLang;
                $this->fillUserData(false, $user->mName);
                $user->mName            = $wgContLang->ucfirst($this->userdata['username']);
                $user->mEmail           = $this->userdata['user_email'];
        }


Now the username is auto-capitalized to match wikimedia behavior. The problem before was the javascript in the mediawiki login page would auto-capitalize the username in the second round of logins, which would end up calling this again with the different case. Now they should match. There might be UTF-8 or other character set issues here, but I'm dealing w/ mainly latin-charset users.

-m
maxslug
Registered User
Posts: 17
Joined: Sun Oct 13, 2002 10:33 pm
Location: San Francisco, CA
Contact:

Re: Duplicate entry on second login

by maxslug » Tue Jun 04, 2013 9:00 pm

  1. Change all lowercase usernames without duplicates to Uppercase
  2. Change all lowercase usernames with duplicates to Uppercaselower
  3. Merge the *lower account into the Uppercase account using https://www.mediawiki.org/wiki/Extension:UserMerge

Note that the UserMerge extension will not work on lowercase names. That's why the first two steps are required. Sorry, I don't have a lot of users, so I didn't script this, I just did the edits to the wikiusers table directly.

Code: Select all

mysql> select user_id, user_name from wikiuser;
+---------+-------------------+
| user_id | user_name         |
+---------+-------------------+
|      2 | nodupe             |
|      3 | Dupe               |
|      4 | dupe               |

and then

Code: Select all

mysql> update wikiuser set user_name = 'Nodupe' where user_id=2;
mysql> update wikiuser set user_name = 'Dupelower' where user_id=4;



If you have more than a handful, you should probably put something together in your scripting language of choice (perl,php,ruby,python,etc) to do this above step.

Note: user_names can't contain underscores and other misc mediawiki restrictions.
-m
maxslug
Registered User
Posts: 17
Joined: Sun Oct 13, 2002 10:33 pm
Location: San Francisco, CA
Contact:

Re: Duplicate entry on second login

by erkpower » Tue Dec 10, 2013 12:14 am

maxslug wrote:I think I found the bug and have a fix for it :

This function :

Code: Select all

        public function initUser(&$user, $autocreate = true)
        {
                $this->fillUserData(false, $user->mName);
                $user->mName           = $this->userdata['username'];
                $user->mEmail           = $this->userdata['user_email'];
        }


Should be changed to :

Code: Select all

        public function initUser(&$user, $autocreate = true)
        {
                global $wgContLang;
                $this->fillUserData(false, $user->mName);
                $user->mName            = $wgContLang->ucfirst($this->userdata['username']);
                $user->mEmail           = $this->userdata['user_email'];
        }


Now the username is auto-capitalized to match wikimedia behavior. The problem before was the javascript in the mediawiki login page would auto-capitalize the username in the second round of logins, which would end up calling this again with the different case. Now they should match. There might be UTF-8 or other character set issues here, but I'm dealing w/ mainly latin-charset users.

-m

Where is this at?
erkpower
Registered User
Posts: 2
Joined: Mon Dec 09, 2013 11:59 pm
Contact:

Re: Duplicate entry on second login

by erkpower » Wed Jan 01, 2014 1:00 pm

Anyone?
erkpower
Registered User
Posts: 2
Joined: Mon Dec 09, 2013 11:59 pm
Contact: