News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

[4764] Uppercase Usernames can't be found (using postgres)

Started by habakuk, June 15, 2011, 07:55:35 AM

Previous topic - Next topic

habakuk

SMF 2.0rc5
MacOSX 10.6.x
Apache 2.x
PHP 5.3.x
Postgresql 8.3.x
Using English UTF-8 and German UTF-8

PROBLEM:
I do have usernames that start with uppercase and some with lowercase letters. Using the search function (index.php?action=admin;area=viewmembers;sa=search;) to find members does not work, if the username starts with a uppercase letter.

Searching for "Testuser" does not find the user
Searching for "*estuser" does find the user.

I guess, there is a problem with case sensitivity in the search function using postgresql.

cheers



habakuk

Update:

In the mean time, I upgraded to the 2.0 final release. Yet, the problem persists.

habakuk


emanuele

#3
Yes, can I confirm it.

With MySQL the search is case-insentive, while with postgreSQL is case-sensitive.

It affects only the search function for members.

Edit: it affects also the normal search if you specify the member name.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

emanuele

This could be a fix.
In Memberlist.php:
Code (search for) Select
'search' => '%' . strtr($smcFunc['htmlspecialchars']($_POST['search'], ENT_QUOTES), array('_' => '\\_', '%' => '\\%', '*' => '%')) . '%',
Code (replace with) Select
'search' => '%' . strtolower(strtr($smcFunc['htmlspecialchars']($_POST['search'], ENT_QUOTES), array('_' => '\\_', '%' => '\\%', '*' => '%'))) . '%',

Code (search for) Select
$fields = array('member_name', 'real_name');
Code (replace with) Select
$fields = array('lower(member_name)', 'lower(real_name)');

Then in Search.php:
Code (search for) Select
'match_possible_users' => 'real_name LIKE ' . implode(' OR real_name LIKE', $realNameMatches),
Code (replace with) Select
'match_possible_users' => 'lower(real_name) LIKE lower(' . implode(' OR real_name LIKE lower(', $realNameMatches) . ')',

And finally in ManageMembers.php
Code (search for) Select
$_POST[$param_name] = strtotime($_POST[$param_name]);
}

Code (add after) Select

elseif ($param_name == 'membername')
{
$_POST[$param_name] = strtolower($_POST[$param_name]);
}


Code (search for) Select
$query_parts[] = '(' . implode( ' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
$where_params[$param_name . '_normal'] = '%' . $parameter . '%';

Code (replace with) Select
if ($param_name == 'membername')
{
$query_parts[] = 'lower(' . implode( ') LIKE {string:' . $param_name . '_normal} OR lower(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal}';
$where_params[$param_name . '_normal'] = '%' . $parameter . '%';
}
else
{
$query_parts[] = '(' . implode( ' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
$where_params[$param_name . '_normal'] = '%' . $parameter . '%';
}


Don't know if I missed anything else.
Tested only partially with MySQL.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Advertisement: