Update quotes and mentions when username is changed

(Dave McClure) #1

A user recently asked me whether he could change his username on our 2 month old site.

He had been lurking for a while and then recently started posting.

When I tried to update it through the admin UI, the big scary warning made me pause:

From looking through the new user list and seeing that many people are accepting the auto-generated name when they first sign up, I’m somewhat anticipating this to become a more frequent occurrence as each user starts to engage more and sees their username in ‘public’ for the first time when they post.

I second the proposal from this long ago topic:

Continuing the discussion from What are the 'consequences' of changing your name?:

But also, how are people dealing with this now?

(Joshua Rosenfeld) #2

I see this as being an insanely expensive database operation. Without knowing the exact structure, it is hard to say, but it would appear that one cannot simply query every post where a user was quoted efficiantly. Mentions might be easier, as they appear to be tracked already - you can view mentions on your profile - but if a user has been around a while, and mentioned a lot, that is a tremendous number of operations to go through and edit every single entry.

(Dave McClure) #3

I’m surprised this doesn’t come up more, though. Or does it and I just am having trouble with search?

(Joshua Rosenfeld) #4

I’m not: I don’t think that many users sign up with a username and then decide to change it months later. From my experience with Discourse (and other sites), most people have a username they tend to use online, and thus don’t have many needs to change it.

I think many people also have no idea that it can be changed, and thus don’t try. Many sites do not allow username changes - financial sites, email sites, corporate sites - so that may have something to do with it as well.

(Sam Saffron) #5

It is a very tricky DB operation cause … when you rename

@foo to @bar… you don’t want to rename @foobar to @barbar nor do you want to touch @bar which may be in a code sample, so you would need to walk every post and integrated with the Markdown parser.

In short

A nightmare.

(Dave McClure) #6

Didn’t we do this recently here for @meglio? Or am I mistaken?

EDIT in my current case, there are just a few quotes that are “broken”, and even that is not so bad. I’m not sure I care that much and it seems like a reasonable compromise to just let the references dangle.

(Dave McClure) #7

I think another thing that is particular about my use case is that its a login-required forum.

So at sign-up time, people have not had a chance to lurk and see what the social norms are for user names on the site yet.

(Gerhard Schlager) #8

Do we really need to update old quotes and mentions? We could use a redirect.

If someone clicks on @foo we could show the profile of @bar and display a hint on the user’s profile (“previously known as foo”).

The old username should still be reserved. The fact that someone can reuse the username “foo” after it was renamed to “bar” is bugging me anyway.

Of course, if a user gets renamed that doesn’t have any quotes or mentions (do we track those numbers?) we could do a simple rename without the redirect.


I appreciate there’s a big legacy issue to consider - but notwithstanding this, perhaps in future you could consider normalising this and storing only the user’s ID, and then resolving the current username every time the ID surfaces in the UX/email digests etc? That’s assuming that the organisation operating the forum doesn’t have absolute retention policies in place to ensure non repudiation.

(Sam Saffron) #10

I always wanted our users routes to be /users/ID/etc this would be a non issue

But… changing this now would be mega painful

(cpradio) #11

So would changing it later :wink:

(Sam Saffron) #12

Well the other issue is that I am the only one that really wants the scheme changed, @eviltrout finds ids in URLs very ugly. In practice renaming users is really super rare, but there is something to be said about the extra flexibility you get with ids, especially if we ever allow Chinese usernames etc.

(cpradio) #13

Yeah, no doubt, my subtle point was, if it is a direction Discourse feels solves a problem (or multiple problems), that waiting especially on this one, will cause even more pain versus biting the bullet sooner. Yes, it is going to hurt regardless, but what is certain, is it will hurt even a bit more, the more it is pushed back (but you know this).

I’m impartial on the whole idea. I see where everyone is coming from with renaming users, but I fear even aliases are not 100%, what happens when User A renames themselves to User B, and then User C renames themselves to User A… now what?

Or if User A renames themselves to User B and then a new user signs up claiming User A’s original username.

(Gerhard Schlager) #14

In my opinion, renaming a user shouldn’t free up that username.


Agreed, and in some use cases, it would probably be illegal to do so.

And if the name was changeable, and I believe there are many reasons why this might be necessary, then a previously known as list should be maintained to support non repudiation.

(Paolo G. Giarrusso) #16

Don’t you do that already? Sometimes? I mean, I can share a link to this thread as https://meta.discourse.org/t/update-quotes-and-mentions-when-username-is-changed/39836?u=blaisorblade but also https://meta.discourse.org/t/foo-bar/39836?u=blaisorblade will work. That is, URLs contain a name with the role of an auto-generated comment for a question, and the actual question ID. Do the same for usernames.

Personally, I’ve already been annoyed by the issue on StackExchange, which is indistinguishable in these technical regards (given the common heritage) — username changes are possible and break mentions, and URLs mix IDs and comments so a solution would be possible by doing it more.

(Jeff Atwood) #17

Just a reminder that users can change their username at will for 3 days after their account is created. See the site setting username change period.

(Paula Kreuzer) #18

Is there any way to implement this already? I’d really like to try this method and add a little “a” into my username to indicate my gender-transition.
In the Fairphone Forum I have 4.5k posts and was probably mentioned and quoted a similar number of times. I don’t think editing all posts mentioning/quoting me would be feasible and also I don’t mind my old name still being displayed in old posts. So a redirect would really be perfect.

How could this be done if at all?

(Andrew Waugh) #19


Have a look here. This would allow you to replace @Paul with @Paula, but you’ll have trouble with replacing Paul with Paula (as you’ll end up with “Pope Paula”, “Peter, Paula and Mary” etc.

(Paula Kreuzer) #20

Thanks for that suggestion.
So I’d create a new user account, change ownership of all posts to the new user and change all references (which shouldn’t be a problem with the usernames paul(a)kreuzer, but if someone answered things like “Hey Paul, …” that would stay untouched)?
I’m not really sure what steps 2 and 4 do.


This would be a problem.

What if I just changed my username (paulkreuzer -> paulakreuzer) and create a new user with the old username (paulkreuzer)? Would quotes and mentions then show that new user?
Then I could enter a redirection into that new user’s description and maybe it’s somehow possible to disallow mentioning that user in the future?