Skip to content

User Import#99

Merged
herbdool merged 1 commit intobackdrop-contrib:1.xfrom
jadamsbit:user_import_fix
Jul 8, 2022
Merged

User Import#99
herbdool merged 1 commit intobackdrop-contrib:1.xfrom
jadamsbit:user_import_fix

Conversation

@jadamsbit
Copy link
Copy Markdown
Contributor

I have been using the user import and found out that the role is being set in the database with the role label instead of the machine name. I looked at the code and in the FeedUserProcessor.inc file on line 625 and noticed the entity role was being set with role label. I changed that line to set with the role name and the issue was resolved.

…f the name. I changed line 625 to be role->name and now the user import works fine.
@herbdool herbdool merged commit abc47e8 into backdrop-contrib:1.x Jul 8, 2022
@herbdool
Copy link
Copy Markdown
Collaborator

herbdool commented Jul 8, 2022

Thank you! Merged

@argiepiano
Copy link
Copy Markdown
Contributor

Just a side comment about this PR.

This PR correctly assigns name (instead of the label) as the value to the user's roles array. However, it does so using an associative array with a key that is also the role's name. This key actually is ignored when the user object is saved, so, this PR doesn't do any harm. But I did want to point out that the key is not needed in the User object's roles array. It's an indexed array, not an associative array.

You can actually see how UserStorageController:preSave() converts it to an indexed array:

    // Prepare user roles.
    if (isset($entity->roles)) {
      $entity->roles = array_values(array_filter($entity->roles));
    }

@herbdool
Copy link
Copy Markdown
Collaborator

Good catch @argiepiano. I'm happy to just remove the key in a new commit. Just to have it cleaned up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants