From eed24900ffa0690bf8d58963d9cae59ef3e03d1c Mon Sep 17 00:00:00 2001
From: Adam J. DiCarlo <adam.dicarlo@gmail.com>
Date: Thu, 15 Mar 2012 11:18:57 -0700
Subject: [PATCH] Issue #1484064: Fix Nodes published through Workbench Moderation don't show in Superfish menu until caches cleared.

---
 superfish.module |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/superfish.module b/superfish.module
index 9bf96ba..f4cfb01 100644
--- a/superfish.module
+++ b/superfish.module
@@ -1026,4 +1026,21 @@ function theme_superfish_build($variables) {
   $output['parent_children'] = $parent_children;
   $output['single_children'] = $single_children;
   return $output;
-}
\ No newline at end of file
+}
+
+/**
+ * Implements hook_workbench_moderation_transition().
+ */
+function superfish_workbench_moderation_transition($node, $previous_state, $new_state) {
+  if ($new_state == 'published' && $previous_state != $new_state) {
+    // When a node gets published through Workbench Moderation, we end up either
+    // not rebuilding our menu cache, or rebuilding it before the new item is
+    // added. This causes the new node not to show up in the superfish menu
+    // caches are cleared or the menu cache is otherwise cleared.
+    $clone = clone $node;
+    menu_node_prepare($clone);
+    if ($clone->menu['mlid']) {
+      menu_rebuild();
+    }
+  }
+}
-- 
1.7.4.1

