Last modified: 2014-10-11 00:59:10 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T54549, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 52549 - Same ID used when merging two case-different users
Same ID used when merging two case-different users
Status: PATCH_TO_REVIEW
Product: MediaWiki extensions
Classification: Unclassified
UserMerge (Other open bugs)
master
All All
: Normal normal (vote)
: ---
Assigned To: Ryan Lane
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-08-05 15:46 UTC by Carl Lewis
Modified: 2014-10-11 00:59 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
quick patch of workaround (1.40 KB, patch)
2013-08-05 17:06 UTC, Carl Lewis
Details

Description Carl Lewis 2013-08-05 15:46:30 UTC
BACKGROUND:
-----------
User accounts on Wikimedia are case-sensitive.

After switching to the LdapAuthentication extension, existing users who authenticated against the ldap server are munged to be "Propercase". Even if there is an identical account in the wiki user table, LdapAuthentication extension creates a new account anyway, so that there are now two in the system:

   MyUserName
   Myusername


PROBLEM:
--------
When attempting to merge two accounts with the same text, but different casing, this extension selects the same ID for BOTH, causing no merge to take place and the selected account to be LOST if the delete option is checked.

This is because User::newFromName selects the incorrect user id.

Note I am using the latest GIT master of UserMerge. (extension version reports 1.7.0, even though the extension download page shows 1.8.0)


WORK AROUND:
------------
I corrected this in my local build by changing:

FROM:
$objOldUser = User::newFromName( $olduser_text );
$olduserID = $objOldUser->idForName();

$objNewUser = User::newFromName( $newuser_text );
$newuserID = $objNewUser->idForName();


TO:
$olduserID = User::idFromName( $olduser_text );
$objOldUser = User::newFromId( $olduserID );

$newuserID = User::idFromName( $newuser_text );
$objNewUser = User::newFromId( $newuserID );


I also added the following as another check, but could use an i18n:

//check if attempting to merge into same user
} elseif($olduserID == $newuserID) { 
   $validNewUser = false;
   $out->addHTML("new user cannot be the same as the old one");
} else {
   // newuser looks good
   $validNewUser = true;
}
Comment 1 T. Gries 2013-08-05 16:24:16 UTC
Seems to be a valid point, thanks for reporting this.

Are you able (have you ever tried?) to formally submit a commit to Gerrit? Otherwise I will do, don't be worry, it's not worth that you install the requirements for submitting to gerrit.

But can you add at least a formal "diff -bru <original-directory> <patched-code-directory>" as attachment to this bugzilla, based on the latest code, please read the following:


Regarding this:

> Note I am using the latest GIT master of UserMerge. (extension version reports
1.7.0, even though the extension download page shows 1.8.0)

This is not true, Special:Version reports 1.8.0 for me. Can you check your latest version or make in any case a fresh checkout from git -- I cannot see "1.7.0" elsewhere in the current code!
Comment 2 Carl Lewis 2013-08-05 17:06:27 UTC
Created attachment 13063 [details]
quick patch of workaround

Note that this includes an error condition if both id's match. The text in this patch is hard-coded.
Comment 3 Carl Lewis 2013-08-05 17:07:38 UTC
My apologies -- the latest snapshot is 1.7; git master is indeed 1.8

I merged my changes into 1.8 and attached the patch as requested.
Comment 4 Gerrit Notification Bot 2013-08-05 20:08:19 UTC
Change 77814 had a related patch set (by Wikinaut) published:
Fixed problem of not merging two case-different usernames

https://gerrit.wikimedia.org/r/77814
Comment 5 T. Gries 2013-08-05 20:10:42 UTC
Carl, you can checkout the last patch set and try. Please comment in gerrit whether it works as designed.

Here is the command you can simply apply in the UserMerge directory:

git fetch https://wikinaut@gerrit.wikimedia.org/r/mediawiki/extensions/UserMerge refs/changes/14/77814/3 && git checkout FETCH_HEAD
Comment 6 Andre Klapper 2013-08-06 12:00:29 UTC
["patch-need-review" keyword refers to Bugzilla only, not Gerrit - removing]
Comment 7 Tyler Romeo 2013-08-06 20:31:21 UTC
Changing this to LdapAuthentication. The bug is that when you switch from normal database authentication over to LDAP authentication, the extension starts creating new accounts in the database using "canonical username" form.
Comment 8 T. Gries 2013-08-06 21:32:39 UTC
but the test for equality of old and new names (=> error text) is an improvement in UserMerge.
Comment 9 Tyler Romeo 2013-08-06 21:34:37 UTC
I'm not so sure about that. The idea behind User::getCanonicalName() is that the returned string is the unique name by which the user is identified. If two names are passed into that function and the same canonical value is returned, then those two users should be considered identical. To bypass that functionality would mean treating identical users differently.

The fix for this should be for LdapAuthentication to provide some sort of migration script that fixes the case of usernames in the database.
Comment 10 T. Gries 2013-08-06 21:37:52 UTC
I only mean the check, if same names were entered into the input fields. Haven't studied the code if this is already checked previously.
Comment 11 Tyler Romeo 2013-08-06 21:42:02 UTC
Ah yes true. Does your current patch do that? If so then we can merge that (although this bug will still be open since it's still a problem with LdapAuthentication).
Comment 12 T. Gries 2013-08-06 21:48:01 UTC
see lines 94-96 and the new message text 'usermerge-same-old-and-new-user' in the i18n file:


} elseif( $olduserID == $newuserID ) {
   $validNewUser = false;
   $out->wrapWikiMsg( "<div class='error'>$1</div>", array( 'usermerge-same-old-and-new-user' ) );
} else {


I think you will ask me quickly to make a separate commit for this ;-)
Comment 13 T. Gries 2013-08-06 22:11:25 UTC
(In reply to comment #12)
> see lines 94-96 and the new message text 'usermerge-same-old-and-new-user' in
> the i18n file:
> 
> 
> } elseif( $olduserID == $newuserID ) {
>    $validNewUser = false;
>    $out->wrapWikiMsg( "<div class='error'>$1</div>", array(
> 'usermerge-same-old-and-new-user' ) );
> } else {
> 
> 
> I think you will ask me quickly to make a separate commit for this ;-)
separate commit is => https://gerrit.wikimedia.org/r/#/c/77980/
Comment 14 Carl Lewis 2013-08-07 13:27:24 UTC
While it is true that Ldap is the original culprit, how does one clean up the aftermath? Commit 77980 will only block future merge attempts.
Comment 15 T. Gries 2013-08-07 13:32:08 UTC
(In reply to comment #14)
> While it is true that Ldap is the original culprit, how does one clean up the
> aftermath? Commit 77980 will only block future merge attempts.

No, this does not block further merge attemps, check the code, it is the same as in https://gerrit.wikimedia.org/r/77814 < this one should be abandoned, perhaps.
Comment 16 Gerrit Notification Bot 2014-10-11 00:59:10 UTC
Change 77814 abandoned by Legoktm:
Fixed problem of not merging two case-different usernames

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links