Index: workflow.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/workflow/workflow.module,v
retrieving revision 1.83.2.18
diff -u -r1.83.2.18 workflow.module
--- workflow.module	25 Oct 2010 02:13:48 -0000	1.83.2.18
+++ workflow.module	11 Jul 2011 13:10:46 -0000
@@ -1476,20 +1476,35 @@
  * Expose each transition as a hook.
  */
 function workflow_hook_info() {
-  $states = workflow_get_states();
+  global $language;
+  static $cache;  
+  if (!$cache) {
+    // static cache per language, since already translated data
+    $cache[$language->language]['states'] = workflow_get_states();
+  }
+  $states = $cache[$language->language]['states'];
+  
   if (!$states) {
     return;
   }
   $trigger_page = substr($_GET['q'], 0, 28) == 'admin/build/trigger/workflow';
-  if ($trigger_page && $wid = arg(4)) {
-    $result = db_query("SELECT tm.type, w.wid, w.name, ws.state, wt.tid, wt.sid, wt.target_sid FROM {workflow_type_map} tm LEFT JOIN {workflows} w ON tm.wid = w.wid LEFT JOIN {workflow_states} ws ON w.wid = ws.wid LEFT JOIN {workflow_transitions} wt ON ws.sid = wt.sid WHERE w.wid = %d AND wt.target_sid IS NOT NULL ORDER BY tm.type, ws.weight", $wid);
-  }
-  else {
-    $result = db_query("SELECT tm.type, w.wid, w.name, ws.state, wt.tid, wt.sid, wt.target_sid FROM {workflow_type_map} tm LEFT JOIN {workflows} w ON tm.wid = w.wid LEFT JOIN {workflow_states} ws ON w.wid = ws.wid LEFT JOIN {workflow_transitions} wt ON ws.sid = wt.sid WHERE wt.target_sid IS NOT NULL ORDER BY tm.type, ws.weight");
-  }
-  while ($data = db_fetch_object($result)) {
-    $pseudohooks['workflow-'. $data->type .'-'. $data->tid] = array('runs when' => t('When %type moves from %state to %target_state', array('%type' => $data->type, '%state' => $states[$data->sid], '%target_state' => $states[$data->target_sid])));
+  $wid = ($trigger_page && arg(4) ? arg(4) : 'all');
+  
+  // check, if static cache needs an update 
+  if (!isset($cache[$language->language][$wid])) {
+    if ($wid != 'all') {
+      $result = db_query("SELECT tm.type, w.wid, w.name, ws.state, wt.tid, wt.sid, wt.target_sid FROM {workflow_type_map} tm LEFT JOIN {workflows} w ON tm.wid = w.wid LEFT JOIN {workflow_states} ws ON w.wid = ws.wid LEFT JOIN {workflow_transitions} wt ON ws.sid = wt.sid WHERE w.wid = %d AND wt.target_sid IS NOT NULL ORDER BY tm.type, ws.weight", $wid);
+    }
+    else {
+      $result = db_query("SELECT tm.type, w.wid, w.name, ws.state, wt.tid, wt.sid, wt.target_sid FROM {workflow_type_map} tm LEFT JOIN {workflows} w ON tm.wid = w.wid LEFT JOIN {workflow_states} ws ON w.wid = ws.wid LEFT JOIN {workflow_transitions} wt ON ws.sid = wt.sid WHERE wt.target_sid IS NOT NULL ORDER BY tm.type, ws.weight");
+    }
+    while ($data = db_fetch_object($result)) {
+      $cache[$language->language][$wid]['workflow-'. $data->type .'-'. $data->tid] = array('runs when' => t('When %type moves from %state to %target_state', array('%type' => $data->type, '%state' => $states[$data->sid], '%target_state' => $states[$data->target_sid])));
+    }
   }
+
+  $pseudohooks = $cache[$language->language][$wid];
+  
   // $pseudohooks will not be set if no workflows have been assigned
   // to node types.
   if (isset($pseudohooks)) {

