diff --git includes/menu.inc includes/menu.inc index a3121c7..2861476 100644 --- includes/menu.inc +++ includes/menu.inc @@ -2694,9 +2694,10 @@ function _menu_navigation_links_rebuild($menu) { } if ($menu_links) { // Make sure no child comes before its parent. - array_multisort($sort, SORT_NUMERIC, $menu_links); + asort($sort, SORT_NUMERIC); - foreach ($menu_links as $item) { + foreach (array_keys($sort) as $path) { + $item = $menu_links[$path]; $existing_item = db_select('menu_links') ->fields('menu_links', array( 'mlid', @@ -3460,9 +3461,9 @@ function _menu_router_build($callbacks) { $sort[$path] = $number_parts; } } - array_multisort($sort, SORT_NUMERIC, $menu); + asort($sort, SORT_NUMERIC); // Apply inheritance rules. - foreach ($menu as $path => $v) { + foreach (array_keys($sort) as $path) { $item = &$menu[$path]; if (!$item['_tab']) { // Non-tab items. diff --git modules/simpletest/tests/menu_test.module modules/simpletest/tests/menu_test.module index 8e8173e..f8c7f99 100644 --- modules/simpletest/tests/menu_test.module +++ modules/simpletest/tests/menu_test.module @@ -310,6 +310,33 @@ function menu_test_menu() { 'access callback' => TRUE, ); + // When the any property is first within a menu item, if we sort all the menu + // items by value we can end up with PHP notices when if tries to convert an + // object to an int. The access arguments and page arguments are allowed to + // contain objects, but we only test access arguments here. We deliberately + // set that case up here, so we can test that this is not what we're doing. + $common_properties = array( + 'title' => 'An item with array and object callback arguments', + 'page callback' => 'menu_test_callback', + 'access callback' => TRUE, + ); + // By adding four different menu items we ensure that we have each 'type' of + // our access arguments surrounded by the of 'type', this ensures that as + // least some kind of value sorting will occur between them. + $items['menu-test/callback-arguments1'] = array( + // This is an object that will get casted to an int (and cause a PHP notice). + 'access arguments' => array((object) array('a', 'b')), + ) + $common_properties; + $items['menu-test/callback-arguments2'] = array( + 'access arguments' => array(0), + ) + $common_properties; + $items['menu-test/callback-arguments3'] = array( + 'access arguments' => array((object) array('c', 'd')), + ) + $common_properties; + $items['menu-test/callback-arguments4'] = array( + 'access arguments' => array(1), + ) + $common_properties; + return $items; }