#16014 closed defect (bug) (fixed)
Search wildcards should only affect multisite
Reported by: | nacin | Owned by: | |
---|---|---|---|
Milestone: | 3.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Users | Keywords: | regression has-patch |
Focuses: | Cc: |
Description
Wildcard restrictions to get_search_sql() should only affect multisite. Right now they affect wp-admin/users.php.
3:15 nacin we need an implicit_wildcard flag in WP_User_Query or something 3:16 nacin and it only does trailing wildcards, which is probably a change 3:17 nacin good for scaling a network 3:17 nacin poor for wp-admin/users 3:19 nacin basically, we'd need to allow get_search_sql() to do leading wildcards 3:19 nacin and offer an implicit wildcard through users.php
Attachments (4)
Change History (24)
#5
@
14 years ago
Took me too long to figure out. The patch seems to be working.
Searching for admin
on a single site:
WHERE 1=1 AND (user_login LIKE '%admin%' OR user_nicename LIKE '%admin%')
On Multisite:
WHERE 1=1 AND (user_login LIKE 'admin' OR user_nicename LIKE 'admin')
However, searching for admin*
on a single site results in “No matching users were found”:
WHERE 1=1 AND (user_login LIKE '%admin%' OR user_nicename LIKE '%admin*%')
On Multisite, it's OK:
WHERE 1=1 AND (user_login LIKE 'admin' OR user_nicename LIKE 'admin%')
Is this correct? Perhaps $search = trim($search, '*')
is needed for a single site too?
#9
@
14 years ago
Should we be checking is_multisite() or is_network_admin(). I think these searches are fine as long as they are bounded to a particular blog as they are in wp-admin/users.php.
#13
@
14 years ago
Why are we burying the logic deep in the searching code rather than where it is called.
A plugin may want to do something using the searching code but allowing the banned search types and will now have to duplicate the code.
#15
@
14 years ago
Exposing wild = 'trailing|leading|both' in WP_User_Query sounds good. Let the callers decide what they want. Or, handle * in search strings down in get_search_sql() and skip the args, leaving it up to callers to add leading and trailing *.
#16
@
14 years ago
WP_User_Query::prepare_query() trims leading and trailing asterisks and passes wild = trailing | leading | both to get_search_sql() accordingly. WP_Users_List_Table::prepare_items() always adds leading and trailing asterisks to the search term. WP_MS_Users_List_Table::prepare_items() allows user to pass a trailing asterisk in the search and strips all other asterisks.
#18
@
14 years ago
- Resolution set to fixed
- Status changed from new to closed
(In [17189]) Default to leading and trailing wildcards for site user searches. Require explicit trailing wildcard asterisk request for network user searches. Disallow leading wildcards for network user searches. Move wildcard policy up the stake, allowing more flexibility in WP_User_Query. Props SergeyBiryukov. fixes #16014
Why must we do this for 3.1?
This sounds like something that can wait for 3.2