When no role is selected for available users filtering. Instead of displaying all users, no-one is available.

In user_reference.module while building query in _user_reference_potential_references_standard(), the user role filter setting test always return true for the following condition : !in_array(DRUPAL_AUTHENTICATED_RID, $field['settings']['referenceable_roles']).

Comments

JulienD’s picture

Status: Active » Needs review
StatusFileSize
new920 bytes

Here's a .patch file to solve the fact that no results are returned in the user_reference field when no roles are selected in the field settings.

I just used a "array_filter" on the field user_reference to exclude empty results.

fgm’s picture

Status: Needs review » Needs work

With the patch in #1, $roles is being assigned twice in a row without change: the first assignment is therefore useless.

And it does not apply because you rolled it in references/node_reference instead of references/

JulienD’s picture

StatusFileSize
new1.15 KB

I updated my patch to allow it to be applied from the root of the module and I removed the first declaration of $roles as suggested in #2.

fgm’s picture

You don't really want to leave a dpq() in the patch, do you ? ;-)

JulienD’s picture

StatusFileSize
new1002 bytes

Even if the dpq() is really useful, I agree this function should not be there. My cold has a bad impact on my attention. Sorry

JulienD’s picture

Status: Needs work » Needs review
fgm’s picture

Status: Needs review » Needs work

Cool, now can we have a test with that ?