diff --git a/core/includes/menu.inc b/core/includes/menu.inc index d56c53b..aeb0d8a 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -275,6 +275,20 @@ const MENU_MAX_DEPTH = 9; */ /** + * Reserved key to identify the most specific menu link for a given path. + * + * The value of this constant is a hash of the constant name. We use the hash + * so that the reserved key is over 32 characters in length and will not + * collide with allowed menu names: + * @code + * sha1('MENU_PREFERRED_LINK') = 1cf698d64d1aa4b83907cf6ed55db3a7f8e92c91 + * @endcode + * + * @see menu_link_get_preferred() + */ +const MENU_PREFERRED_LINK = '1cf698d64d1aa4b83907cf6ed55db3a7f8e92c91'; + +/** * Returns the ancestors (and relevant placeholders) for any given path. * * For example, the ancestors of node/12345/edit are: @@ -2401,7 +2415,7 @@ function menu_link_get_preferred($path = NULL, $selected_menu = NULL) { if (empty($selected_menu)) { // Use an illegal menu name as the key for the preferred menu link. - $selected_menu = '__preferred__'; + $selected_menu = MENU_PREFERRED_LINK; } if (!isset($preferred_links[$path])) { @@ -2459,9 +2473,9 @@ function menu_link_get_preferred($path = NULL, $selected_menu = NULL) { _menu_translate($candidate_item, $map); if ($candidate_item['access']) { $preferred_links[$path][$menu_name] = $candidate_item; - if (empty($preferred_links[$path]['__preferred__'])) { + if (empty($preferred_links[$path][MENU_PREFERRED_LINK])) { // Store the most specific link. - $preferred_links[$path]['__preferred__'] = $candidate_item; + $preferred_links[$path][MENU_PREFERRED_LINK] = $candidate_item; } } }