diff --git a/includes/Entity/Workflow.php b/includes/Entity/Workflow.php index 9964f0ff99b70bf22b52738bf7b07a27c799c740..76fe2a981f906bd522c130a42edda633f6b02923 100644 --- a/includes/Entity/Workflow.php +++ b/includes/Entity/Workflow.php @@ -15,6 +15,7 @@ class Workflow extends Entity implements WorkflowInterface { public $tab_roles = array(); public $options = array(); protected $creation_sid = 0; + protected $rebuilding = FALSE; // Attached States. public $states = NULL; @@ -101,6 +102,12 @@ class Workflow extends Entity implements WorkflowInterface { * Rebuild internals that get saved separately. */ protected function rebuildInternals() { + // Avoid recursive rebuilding. + if ($this->rebuilding) { + return; + } + $this->rebuilding = TRUE; + // Insert the type_map when building from Features. if (isset($this->typeMap)) { foreach ($this->typeMap as $node_type) { @@ -204,6 +211,7 @@ class Workflow extends Entity implements WorkflowInterface { $this->states = $this->transitions = NULL; $this->getStates(TRUE, TRUE); $this->getTransitions(FALSE, array(), TRUE); + $this->rebuilding = FALSE; } /** @@ -695,7 +703,7 @@ class Workflow extends Entity implements WorkflowInterface { // @todo: importing Roles is incomplete when user language is not English. // function user_roles() translates DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID - $role_map = workflow_get_roles(NULL); + $role_map = workflow_get_roles(NULL, FALSE); // See also https://drupal.org/node/1702626 . foreach ($roles as $key => $rid) { diff --git a/workflow.module b/workflow.module index 07c0b9cb296d38ca082b33c2c89bbac20b984a7a..432ad0aba5d919c7e43adc203c902be28d79f15a 100644 --- a/workflow.module +++ b/workflow.module @@ -574,12 +574,13 @@ function workflow_execute_transition($entity_type, $entity, $field_name, $transi * @return array * Array of role names keyed by role ID, including the 'author' role. */ -function workflow_get_roles($permission = 'participate in workflow') { +function workflow_get_roles($permission = 'participate in workflow', $translate_roles = TRUE) { static $roles = NULL; if (!$roles[$permission]) { - $roles[$permission][WORKFLOW_ROLE_AUTHOR_RID] = '(' . t(WORKFLOW_ROLE_AUTHOR_NAME) . ')'; + $role_author_name = $translate_roles ? t(WORKFLOW_ROLE_AUTHOR_NAME) : WORKFLOW_ROLE_AUTHOR_NAME; + $roles[$permission][WORKFLOW_ROLE_AUTHOR_RID] = '(' . $role_author_name . ')'; foreach (user_roles(FALSE, $permission) as $rid => $role_name) { - $roles[$permission][$rid] = check_plain(t($role_name)); + $roles[$permission][$rid] = $translate_roles ? check_plain(t($role_name)) : $role_name; } } return $roles[$permission];