If users are allowed to change their user name in Drupal, the connection to vBulletin through DrupalvB will break. To avoid this problem, make the following changes in your code:
Step 1) Find the following line in drupal_vb.module (around line 620):
_drupalvb_update_vb_user($edit_user->name, md5($edit['pass']), $edit['mail'], $userinfo['salt']);
And change it to this:
_drupalvb_update_vb_user($edit_user->name, $edit['name'], $edit['pass'], $edit['mail'], $userinfo['salt']);
By making this change you are passing both the existing user information ($edit_user) and the new user information ($edit) to the _drupalvb_update_vb_user function. I also have removed the md5 from the function call above since I seemed to have some problems with it, and have read on other posts to remove it. Not sure what the current developers think.
Step 2) Find the following line in drupalvb.inc.php (around line 196):
function _drupalvb_update_vb_user($username, $password, $email, $salt) {
And change it to this:
function _drupalvb_update_vb_user($orig_username, $username, $password, $email, $salt){
$orig_username is the original username that we are passing over to this function as reference.
Step 3) Find the following line in drupalvb.inc.php (around line 208):
db_query(_drupalvb_prefix("UPDATE {user} SET password = '%s', passworddate = '%s', salt = '%s', email = '%s', lastactivity = '%s' WHERE username = '%s'"), $passhash, $passdate, $salt, $email, $lastdate, $username);
And change it to this:
db_query(_drupalvb_prefix("UPDATE {user} SET username = '%s', password = '%s', passworddate = '%s', salt = '%s', email='%s', lastactivity = '%s' WHERE username = '%s'"), $username, $passhash, $passdate, $salt, $email, $lastdate, $orig_username);
So this code updates the user name in vBulletin in the case where we find a match for the $orig_username and $username <> $orig_username.
Step 4) Find the following line in drupalvb.inc.php (around line 211):
db_query(_drupalvb_prefix("UPDATE {user} SET email = '%s', lastactivity = '%s' WHERE username = '%s'"), $email, $lastdate, $username);
And change it to this:
db_query(_drupalvb_prefix("UPDATE {user} SET username = '%s', email = '%s', lastactivity = '%s' WHERE username = '%s'"), $username, $email, $lastdate, $orig_username);
This ensures username is updated if there is a difference between $orig_username and $username. Let me know if there are any questions.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | drupalvb-DRUPAL-5--2.username-locale.patch | 4.98 KB | sun |
| #6 | drupalvb-DRUPAL-5--2.username.patch | 2.43 KB | sun |
| #3 | db_disconnect_01.patch | 1.59 KB | stevenpatz |
| #3 | db_disconnect_02.patch | 987 bytes | stevenpatz |
Comments
Comment #1
sunCould you please create a real patch? See http://drupal.org/patch/create
Also, since 5.x-2.x has been completely re-written and a first release candidate is about to be released, it would be more helpful if this patch was against 5.x-2.x.
Comment #2
sgdev commentedI'd like to help you out, but I'm actually the executive of a company and not a developer. I don't have any tools on my machine other than the ability to review code. Feel free to use it as you like.
Comment #3
stevenpatzhere are two patches.
Comment #4
sunAlways create patches with
diff -up, please. You should also consider to create patches against CVS, so above patches would be just in one file. See http://drupal.org/patch/create for further information. Since you're working on Windows, I recommend using TortoiseCVS to perform CVS checkouts. You do not need a CVS account to checkout from CVS.To the patch: vB's help mentions:
So I think we need an additional query after changing a username.
Comment #5
sgdev commentedMaybe the md5() should stay in the
db_disconnect_02.patchpatch? I'm not sure of the designer's intent.Comment #6
sunNope, that's correct, since drupalvb_update_user() already generates the password hash.
Re-rolled the patch against latest DRUPAL-5--2.
Comment #7
sun#142368: Login error if default language is not English has been marked duplicate of this issue.
We need more flexibility for user account updates to support altering of additional values. Attached patch implements this, needs review + testing.
Comment #8
sunI've committed the last patch now. Thanks.
Comment #9
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.