diff -u includes/common.inc includes/common.inc --- includes/common.inc 20 Sep 2010 04:57:39 -0000 +++ includes/common.inc 20 Sep 2010 15:17:35 -0000 @@ -5041,14 +5041,15 @@ $element += array('#links' => array()); foreach (element_children($element) as $key) { $child = &$element[$key]; - // This element may have children with #links that need to be recursively - // merged. If not, this will at least force the child to have #links - // defined as an empty array. - $child = drupal_pre_render_links($child); // If the child has not been printed yet and the user has access to it, - // merge its links in to the parent and mark them as having been printed - // already (so that they cannot be mistakenly rendered twice). + // merge its links in to the parent. if (empty($child['#printed']) && (!isset($child['#access']) || $child['#access'])) { + // The child element itself may have children with #links that need to be + // recursively merged. (If not, calling this will at least guarantee that + // $child['#links'] is defined, so that it can be used below.) + $child = drupal_pre_render_links($child); + // Merge in the links and mark the child as having been printed already + // (so that its links cannot be mistakenly rendered twice). $element['#links'] += $child['#links']; $child['#printed'] = TRUE; }