When use features to export/import roles, it will create different role ids some times in a co-operating development environment.

While in rules 'Send mail to all users of a role' is only saving roles id in rules config.

As roles name are unique, we can save roles name in rules config.

Then, the features with rules will work perfectly!

Comments

rogical’s picture

Title:Load roles by name for better feature integration» Save roles name than roles id in rules config for better feature integration
Issue summary:View changes
rogical’s picture

Status:Active» Needs review
StatusFileSize
new4.09 KB
FAILED: [[SimpleTest]]: [MySQL] 349 pass(es), 0 fail(s), and 2 exception(s).
[ View ]

This patch changes role id to role name in action 'Send mail to all users of a role'

Status:Needs review» Needs work

The last submitted patch, 2: rules-2145837.patch, failed testing.

rogical’s picture

This patch doesn't pass testing due to haven't run update before testing.

rogical’s picture

StatusFileSize
new5.75 KB
FAILED: [[SimpleTest]]: [MySQL] 349 pass(es), 0 fail(s), and 2 exception(s).
[ View ]

This patch adds an update path than hook update, so users can run update multiple times, this is useful for those projects with multiple team.

rogical’s picture

Status:Needs work» Needs review

Status:Needs review» Needs work

The last submitted patch, 5: rules-2145837-use-update-path.patch, failed testing.

rogical’s picture

Status:Needs work» Needs review
StatusFileSize
new5.93 KB
FAILED: [[SimpleTest]]: [MySQL] 349 pass(es), 0 fail(s), and 2 exception(s).
[ View ]

Add santity check.

Status:Needs review» Needs work

The last submitted patch, 8: rules-2145837-use-update-path-1.patch, failed testing.

The last submitted patch, 8: rules-2145837-use-update-path-1.patch, failed testing.

rogical’s picture

Status:Needs work» Needs review
StatusFileSize
new5.93 KB

This patch has two parts:

1. change rules to use role name than role id

2. add an update path in rules config, users can run the update to update role id to role name. (Why not hook update? hook update only run once, but there're may be new legal rules added through features.)

For those want to export roles name than roles id in rules feature, first need to run the update, then re-export the rules.

timwood’s picture

Status:Needs review» Reviewed & tested by the community

Tested #11 patch against 7.x-2.6. Applied cleanly and works fine. When editing a rule previously exported to Features I had to remove the "Send mail to all users of a role" action from the rule and re-add it in order for Features to recognize it changed from ID to name based.

After re-exporting feature with drush, the only change is from numeric role ID storage to name, as expected. I expect manually updating any rules based features would work. Here are the changes of my re-exported feature as reported by git diff:

-            "roles" : { "value" : { "5" : "5" } },
+            "roles" : { "value" : { "ROLE NAME" : "ROLE NAME" } },
fago’s picture

Status:Reviewed & tested by the community» Needs work

Patch violates coding standards and does not seem to pass the bot, so it cannot be rtbc. Besides that we cannot do that when it breaks existing exports. Generally, I'm unsure this is the right approach as the role edit UI allow you to rename roles without changing IDs, so it's probably confusing. Instead I think using role_export module is the better alternative.