diff options
Diffstat (limited to 'includes/menu.inc')
-rw-r--r-- | includes/menu.inc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/includes/menu.inc b/includes/menu.inc index cff3ef5d8..706347278 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -2063,16 +2063,17 @@ function menu_link_save(&$item) { // If not derived from a router item, we respect the specified menu name. $query->condition('menu_name', $item['menu_name']); } + // Find the parent - it must be unique. $parent_path = $item['link_path']; do { $parent = FALSE; $parent_path = substr($parent_path, 0, strrpos($parent_path, '/')); - $query->condition('link_path', $parent_path); - $query_cnt = $query; + $new_query = clone $query; + $new_query->condition('link_path', $parent_path); // Only valid if we get a unique result. - if ($query_cnt->countQuery()->execute()->fetchField() == 1) { - $parent = $query->fields('menu_links')->execute()->fetchAssoc(); + if ($new_query->countQuery()->execute()->fetchField() == 1) { + $parent = $new_query->fields('menu_links')->execute()->fetchAssoc(); } } while ($parent === FALSE && $parent_path); } |