Fork me on GitHub
Subscribe 3

Ticket #113 (wontfix enhancement)

Username not changed in quotes

  • Created: 2010-08-31 13:36:56
  • Reported by: adaur
  • Assigned to: None
  • Milestone: 2.0-alpha3
  • Component: parser
  • Priority: normal

Hello

When an username is changed in profile.php, it is updated everywhere, except on posts including quotes.

Example:

OldUsername wrote:

Text

OldUsername is not updated when replaced by NewUsername.

History

adaur 2010-08-31 13:41:59

  • Description changed. (Diff)

Franz 2010-08-31 14:04:03

Well, yes. But this is definitely not a bug - much rather by design. As quotes are constructed with the username of the user and not with their ID, there is no other choice.

And then, one could say this is a feature, because it allows me to do things like this:

The son of your father wrote:

When an username is changed in profile.php, it is updated everywhere, except on posts including quotes.

However, going through potentially thousands of posts just to fix the display of possibly very old topics when renaming users is far too much.

Franz 2010-08-31 14:27:50

  • Component changed from database to parser.

adaur 2010-08-31 14:38:33

In profile.php, after

$db->query('UPDATE '.$db->prefix.'online SET ident=\''.$db->escape($form['username']).'\' WHERE ident=\''.$db->escape($old_username).'\'') or error('Unable to update online list', __FILE__, __LINE__, $db->error());

adding

$db->query('UPDATE '.$db->prefix.'posts SET message=REPLACE(message,\''.$db->escape($old_username).'\',\''.$db->escape($form['username']).'\') WHERE message LIKE \'%[quote='.$db->escape($old_username).']%\'') or error('Unable to update private messages', __FILE__, __LINE__, $db->error());

solves the bug.

I don't think this query is very expensive, because it is limited to [ quote=Username].

Reines 2010-08-31 16:16:02

If someone has the name "the", that will match any message with quote=the in it, then replace all occurances of the word the, not just the quoted ones. That includes normal words, as well as stuff inside code tags etc.

Also, I'm not sure, but I imagine that REPLACE() is MySQL specific.

adaur 2010-08-31 19:11:47

@Reines:

If you replace the previous query by this one:

$db->query('UPDATE '.$db->prefix.'posts SET message=REPLACE(message,\'[quote='.$db->escape($old_username).']\',\'[quote='.$db->escape($form['username']).']\') WHERE message LIKE \'%[quote='.$db->escape($old_username).']%\'') or error('Unable to update quote informations', __FILE__, __LINE__, $db->error());

I have tested it with success, with two users called Usertest & Usertestt, so the usernames are very similar. And it worked: Usertest has been replaced by Newusertest (or an other username), but the second username (Usertestt) didn't change.

I don't know what is the equivalent for Postegre or SQlite, but you can do:

switch ($db_type)
    {
        case 'mysql':
        case 'mysqli':
        case 'mysql_innodb':
        case 'mysqli_innodb':
            $db->query('UPDATE '.$db->prefix.'posts SET message=REPLACE(message,\'[quote='.$db->escape($old_username).']\',\'[quote='.$db->escape($form['username']).']\') WHERE message LIKE \'%[quote='.$db->escape($old_username).']%\'') or error('Unable to update quote informations', __FILE__, __LINE__, $db->error());
            break;
    }

That way, you have an extra-feature if your database is MySQL, otherwise, there is no changes and no errors smile.

Reines 2010-10-19 15:05:38

  • Milestone set to 2.0-beta1.

Reines 2010-10-25 11:22:01

  • Milestone changed from 2.0-beta1 to 1.4.4.

Franz 2010-11-26 16:36:58

  • Type changed from bug to enhancement.

Reines 2011-01-26 11:20:26

  • Milestone changed from 1.4.4 to 1.4.5.

Reines 2011-02-21 09:33:30

  • Milestone changed from 1.4.5 to 2.0-beta1.

Reines 2011-02-25 00:50:26

  • Milestone changed from 2.0-beta1 to 2.0-alpha3.

Studio384 2012-11-02 14:22:07

Why is this needed? I don't think there is any other forum software that do this, even lots of selfmade forum software doesn't have this feature...

Franz 2012-11-02 22:32:33

That doesn't mean we shouldn't add it. But granted, we should discuss whether it's really worth it. Not sure whether there is any rock-solid implementation.

Comment edited 1 times (Diff)

Franz 2015-06-26 09:56:07

  • Status changed from open to wontfix.