Skip to content

[3.0] Finds members on PostgreSQL whatever case the search is typed in - #9716

Merged
jdarwood007 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/memberlist-search-case
Oct 4, 2026
Merged

jdarwood007 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/memberlist-search-case

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

On PostgreSQL, searching the member list finds nobody as soon as the search has a capital letter in it. Searching for Admin does not find admin, and neither does ADMIN.

Memberlist::search() folds the columns it searches to lower case when the database is case sensitive:

if (Db::$db->case_sensitive) {
	foreach ($fields as $key => $field) {
		...
		$fields[$key] = 'LOWER(' . $field . ')';
	}
}

and then compared each of them with {string:search}, the search exactly as typed. Only the email search was folded, when it was built. MySQL compares without regard to case anyway, so nothing looked wrong there.

The search is now compared through {string_ci:search}, the type that exists for exactly this: on PostgreSQL it wraps the value in LOWER() to match a folded column, and on MySQL it is an ordinary string. The email search keeps {string:email_search}, since that one is folded already.

Test

MemberlistSearchTest signs in as the administrator and searches the member list for their own name in capitals and capitalised, and expects a link to their profile in the results rather than in the menu. Without the change, on PostgreSQL:

searching the member list for "ADMIN" did not find "admin"
searching the member list for "Admin" did not find "admin"

With it, both pass on MySQL and PostgreSQL.

Overlap with #9597

#9597 (case insensitive comparisons, part 2 of 2) also changes this query, to LIKE {string_ci:search}. It was written against the code before the email search changes (70a2a7d, 7ee5156), which rebuilt the WHERE per field, and it no longer applies there. This is the same fix on the current code, on its own so that it can land without waiting for the rest of #9597; that one drops its hunk for this file when it is rebased.

Found while building the template snapshot tests in #9712, where the member list snapshot searched for "Snapshot" and came back empty on PostgreSQL only.

Issues References (Fixes|Related|Closes)

Related: #9712, #9597

🤖 Generated with Claude Code

On a case sensitive database Memberlist::search() folds the columns it
searches to lower case, but compared them with the search as typed, so
a search with any capital letter in it matched nobody. The search is
now folded to match through {string_ci:}. The email search already was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 5 milestone Oct 4, 2026
@jdarwood007
jdarwood007 merged commit bf6d5c5 into SimpleMachines:release-3.0 Oct 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants