Since upgrading from EntityReference 7.x-1.0 to EntityReference 7.x-1.1, the autocomplete on an entity reference field used to reference users via their profile name has stopped working.

After some debugging, I think I have traced this change in behaviour down to this commit:
http://cgit.drupalcode.org/entityreference/commit/?id=8cbef5ee410b36ca1d...

After stepping through the code with a debugger a few times, I am still none the wiser as to why this code breaks our autocomplete view.

For background, the entityreference view is a user view with a relationship to the user profile entity (profile2), so we can pull through the firstname, lastname etc. and search on these values. Reading through the code and the issue it came from, it appears that this commit was intended to actually fix this issue, rather than cause it.

So for our needs, we would like to use the 7.x-1.1 release, as it is a security release and includes other fixes, but would like to remove this commit, so I'll attach a patch that does that. This patch is mainly for our own needs, but may help someone else in the same situation, and will hopefully prompt some further discussion about why the original commit causes the problem in the first place.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Finn Lewis’s picture

brogdawg’s picture

The patch did fix the problem where searching by profile fields breaks all autocomplete results (https://www.drupal.org/node/1898290#comment-7047750), but I still can't reference users by the profile fields. For example I can start typing a username or user email and it finds the results and displays the profile first and last name but if I try typing in the last name I get no results. In my entity reference view I am searching on all fields, username, user email, profile first and last name.

Is this not the behavior you are experiencing?

zterry95’s picture

Status: Active » Reviewed & tested by the community

confirm this patch works for me.

zterry95’s picture

Status: Reviewed & tested by the community » Active

sorry for update the status carelessly.
this patch fix the autocomplete issue for profile2; but did not fix the problem of searching by the profile2 field.

supriyarajgopal’s picture

Subscribing

supriyarajgopal’s picture

Patch in #8 in https://www.drupal.org/node/1898290 worked for me with the latest dev version of this module.

Regards,
Supriya Rajgopal