Problem/Motivation
The commerce:user selection handler (added in Commerce 2.38 to resolve #3035268) is supposed to allow autocomplete search by both username and email address. However, due to a query construction error, email‑only searches return no results.
Steps to reproduce
- Install Commerce 2.40.
- Go to Add order (
/admin/commerce/orders/add) or Reassign order. - In the customer search field, type a valid email address belonging to an existing user.
- No results appear. Typing a username does show results.
Root cause
The buildEntityQuery() method in UserSearch calls DefaultSelection::buildEntityQuery(), which already forces a condition on the name field. The later orConditionGroup() that adds mail is therefore ignored.
Proposed resolution
Replace the broken query builder with a fresh query that correctly adds an OR condition on both name and mail fields.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3585451-3-usersearch-selection-handler-8.x-2.x.patch | 1.41 KB | knyshuk.vova |
Issue fork commerce-3585451
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
knyshuk.vova commentedAttached a patch to mirror MR
Comment #4
jsacksick commented8.x-2.x is no longer maintained, can you open an MR against 3.x?
Comment #6
knyshuk.vova commentedAdded a branch and an MR against 3.x
Comment #7
anybodyI'd vote to add a test to ensure this never happens again? Create an entry and search for the email address (and the name in another test)
Comment #8
ivnishComment #9
jsacksick commentedThe problem is with these changes, the following is no longer happening:
Plus the bundle filtering (but I guess this doesn't matter much for users as in 99% of the installs there is probably only one bundle.