? features_get_roles.patch
Index: features.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/features/features.module,v
retrieving revision 1.1.2.38
diff -u -r1.1.2.38 features.module
--- features.module	11 Aug 2009 19:31:00 -0000	1.1.2.38
+++ features.module	26 Aug 2009 21:28:18 -0000
@@ -491,3 +491,22 @@
     }
   }
 }
+
+/**
+ * Utility functions ==================================================
+ */
+ 
+/**
+ * Represent the current state of permissions as a role name to role/perm array.
+ */
+function _features_get_roles() {
+  $roles = array();
+  $result = db_query("SELECT r.rid, r.name, p.perm FROM {role} r LEFT JOIN {permission} p ON r.rid = p.rid");
+  while ($row = db_fetch_object($result)) {
+    $roles[$row->name] = array(
+      'rid' => $row->rid,
+      'perm' => explode(', ', $row->perm),
+    );
+  }
+  return $roles;
+}
Index: includes/features.filter.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/features/includes/Attic/features.filter.inc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 features.filter.inc
--- includes/features.filter.inc	11 Aug 2009 15:02:45 -0000	1.1.2.4
+++ includes/features.filter.inc	26 Aug 2009 21:28:18 -0000
@@ -122,18 +122,20 @@
   if ($update || !$format_id) {
     // Format the role IDs into something that can be inserted into the database.
     // This is so painful. See filter.admin.inc line 218. : (
-    $roles = array_flip(user_roles());
+    // We cannot use user_roles() here because it has the names translated.
+    $roles = _features_get_roles();
     $format_rids = array();
     foreach ($format['roles'] as $role_name) {
       // Ensure that each role exists. If it does not, create it and store the rid.
       if (!isset($roles[$role_name])) {
         $record = array('name' => $role_name);
         drupal_write_record('role', $record);
-        $roles[$role_name] = $record['rid'];
+        $roles[$role_name]['rid'] = $record['rid'];
+        $roles[$role_name]['perm'] = array();
       }
       // Retrieve the rid corresponding to each role and add it to the format's rids
       if (isset($roles[$role_name])) {
-        $format_rids[] = $roles[$role_name];
+        $format_rids[] = $roles[$role_name]['rid'];
       }
     }
     if ($format_id && $format_id == variable_get('filter_default_format', 1)) {
Index: includes/features.user.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/features/includes/Attic/features.user.inc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 features.user.inc
--- includes/features.user.inc	11 Aug 2009 15:42:07 -0000	1.1.2.4
+++ includes/features.user.inc	26 Aug 2009 21:28:19 -0000
@@ -86,7 +86,7 @@
 function user_features_revert($module = NULL) {
   // Get all fields defined in this feature
   if (module_hook($module, 'user_default_permissions')) {
-    $roles = _user_features_get_roles();
+    $roles = _features_get_roles();
     $defaults = module_invoke($module, 'user_default_permissions');
     foreach ($defaults as $permission) {
       foreach ($roles as $role_name => $role) {
@@ -113,7 +113,7 @@
  * Implementation of hook_features_rebuild().
  */
 function user_features_rebuild() {
-  $roles = _user_features_get_roles();
+  $roles = _features_get_roles();
 
   // Iterate through default permissions and update the permissions map.
   $defaults = module_invoke_all('user_default_permissions');
@@ -177,21 +177,6 @@
 }
 
 /**
- * Represent the current state of permissions as a role name to role/perm array.
- */
-function _user_features_get_roles() {
-  $roles = array();
-  $result = db_query("SELECT r.rid, r.name, p.perm FROM {role} r LEFT JOIN {permission} p ON r.rid = p.rid");
-  while ($row = db_fetch_object($result)) {
-    $roles[$row->name] = array(
-      'rid' => $row->rid,
-      'perm' => explode(', ', $row->perm),
-    );
-  }
-  return $roles;
-}
-
-/**
  * Save/update an array of roles to the database.
  */
 function _user_features_save_roles($roles) {
