1

This is a request for more information outside of what was given here: User roles and keeping their IDs when using features

Basically, it's the age-old problem of storing Roles in Features, and then migrating or importing them into a new site.

Based on some observations of mine when putting roles into a feature failed, it seems like Drupal takes the Role Feature and imports the stored roles in alphabetical order.

For example, I have some roles on my site that I stored into a feature. They had been originally created and added to my development site in this order:

  • administrator
  • moderator
  • subscriber
  • training
  • announcer
  • blogger
  • manager

However, when I migrated the Features code to a new version of the site on a fresh database install, Drupal took the roles Feature I created, and imported the roles it contained in the following order:

  • administrator RID -> 3
  • announcer RID -> 4
  • blogger RID -> 5
  • manager RID -> 6
  • moderator RID -> 7
  • subscriber RID -> 8
  • training RID -> 9

Is this normal behavior? And, if I just organize my roles into Features in alphabetical order, can I expect them to always be reimported in the same proper RID heirarchy?

1

Roles being imported in alphabetical order has been my experience, too.

But counting on autoincrement IDs to be consistent between multiple sites is never a good idea.

I recommend, instead of relying on the autoincrement IDs to be generated in a particular order, to avoid using autoincrement IDs.

  • For Drupal 6 and Drupal 7, the Role Export module turns Role IDs into hashes of machine names, so they're consistent from site to site, regardless of import order.
  • For Drupal 8, work is in progress to eliminate autoincrement Role IDs altogether.
  • Yeah, I feel like your warning is a good one. I was just hoping to not have to use yet another module to deal with site migration. – David Csonka Feb 29 '12 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.