MyBB Community Forums

Full Version: Usernames that begin with "*" cause errors when viewing Private Messages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
It appears that usernames that begin with an asterisk (*) cause errors, such as "*Gary". I noticed this on my forum when a member called *Matt sent a PM to me. When I go to Private Messaging -> Sent Items, I get an error saying that there's an error in the SQL query, with the error pointing to ",*Matt,".

Considering that this is a fairly glaring bug, one reason why this happened to me might be because I converted from vBulletin to MyBB a year ago. So maybe vBulletin accepts usernames that begin with * but MyBB doesn't? Could someone tell me?

Anyway, I fixed this for myself temporarily by opening private.php. The line causing the actual error is the second instance of the following code:

$users_query = $db->simple_select("users", "uid, username, usergroup, displaygroup", "uid IN ({$get_users})");

A few lines above it, where it says:

$get_users = implode(',', array_unique($get_users));

I replaced it with the following:

$get_users = array_unique($get_users);
$new_get_users = array();

foreach ($get_users as $user)
{
	array_push($new_get_users, '"' . $user . '"');
}

$get_users = implode(',', $new_get_users);

So that all usernames are wrapped in quotes. I'm surprised this hasn't been done already.
Ah, and when I do a little searching for why messages have "N/A (not sent)" in the "Sent to" field, I find this useful thread. So maybe that will help.
And yes, it appears that that thread helped. So, I assume that the problem has since been fixed in the Importer.
I've been meaning to test this for a while and finally got time to do it today.

Either this was caused by a problem during the import or a plugin coz I couldn't reproduce this behavior in a test environment. I made a user *test and sent pms to/from that account and never got any sql errors on either the * account or any other accounts that the PMs were sent to both in the inbox/sent/drafts folders. This was on both 1.6 and 1.6.1

The reason I really wanted to try this out was because of the fix that you provided. AFAIK the $get_users variable just has a list of the uids and not the usernames so it shouldn't matter if the usernames had * in it or not, the username is not used in the queries, just the uids

The fact that the above fix works for you is a little surprising to me, well actually you getting the error was more surprising :p

Yes, $get_users is a list of UIDs, hence the code being uid IN ({$get_users})

As G33K said, it's not that it started with a *, it's just that there was a name/string in there at all, which was caused by the bug in the Merge System; if it's a list of numbers, which is what it is normally, it doesn't need ' ' around each value.
This should be fixed in the svn, but it isn't in the download yet. If I remembered to fix it that is. I wasn't Staff yet when I posted in that thread, so I may have forgotten.