#285309 by pwolanin: menu_name in hook_menu is ignored on updates
parent
6511f56e4b
commit
c17a5e70bc
|
@ -1787,8 +1787,11 @@ function _menu_navigation_links_rebuild($menu) {
|
||||||
$existing_item = db_fetch_array(db_query("SELECT mlid, menu_name, plid, customized, has_children, updated FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", $item['link_path'], 'system'));
|
$existing_item = db_fetch_array(db_query("SELECT mlid, menu_name, plid, customized, has_children, updated FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", $item['link_path'], 'system'));
|
||||||
if ($existing_item) {
|
if ($existing_item) {
|
||||||
$item['mlid'] = $existing_item['mlid'];
|
$item['mlid'] = $existing_item['mlid'];
|
||||||
$item['menu_name'] = $existing_item['menu_name'];
|
// A change in hook_menu may move the link to a different menu
|
||||||
$item['plid'] = $existing_item['plid'];
|
if (empty($item['menu_name']) || ($item['menu_name'] == $existing_item['menu_name'])) {
|
||||||
|
$item['menu_name'] = $existing_item['menu_name'];
|
||||||
|
$item['plid'] = $existing_item['plid'];
|
||||||
|
}
|
||||||
$item['has_children'] = $existing_item['has_children'];
|
$item['has_children'] = $existing_item['has_children'];
|
||||||
$item['updated'] = $existing_item['updated'];
|
$item['updated'] = $existing_item['updated'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
; $Id$
|
||||||
|
name = "Hook menu tests"
|
||||||
|
description = "Support module for menu hook testing."
|
||||||
|
package = Testing
|
||||||
|
version = VERSION
|
||||||
|
core = 7.x
|
||||||
|
files[] = hook_menu.module
|
||||||
|
hidden = TRUE
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Dummy module implementing hook menu to test changing the menu name.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the menu changes during the course of this test. Use a $_GET.
|
||||||
|
*/
|
||||||
|
function hook_menu_menu() {
|
||||||
|
|
||||||
|
$items['menu_name_test'] = array(
|
||||||
|
'title' => t('Test menu_name router item'),
|
||||||
|
'page callback' => 'node_save',
|
||||||
|
'menu_name' => isset($_GET["hook_menu_name"]) ? $_GET["hook_menu_name"] : 'original',
|
||||||
|
);
|
||||||
|
return $items;
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Provides SimpleTests for menu.inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class MenuIncTestCase extends DrupalWebTestCase {
|
||||||
|
/**
|
||||||
|
* Implementation of getInfo().
|
||||||
|
*/
|
||||||
|
function getInfo() {
|
||||||
|
return array(
|
||||||
|
'name' => t('Hook menu tests'),
|
||||||
|
'description' => t('Test menu hook functionality.'),
|
||||||
|
'group' => t('Menu'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of setUp().
|
||||||
|
*/
|
||||||
|
function setUp() {
|
||||||
|
// Enable dummy module that implements hook_menu.
|
||||||
|
parent::setUp('hook_menu');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for menu_name parameter for hook_menu().
|
||||||
|
*/
|
||||||
|
function testMenuName() {
|
||||||
|
$admin_user = $this->drupalCreateUser(array('administer site configuration'));
|
||||||
|
$this->drupalLogin($admin_user);
|
||||||
|
|
||||||
|
$sql = "SELECT menu_name FROM {menu_links} WHERE router_path = 'menu_name_test'";
|
||||||
|
$name = db_result(db_query($sql));
|
||||||
|
$this->assertEqual($name, 'original', t('Menu name is "original".'));
|
||||||
|
|
||||||
|
// Force a menu rebuild by going to the modules page.
|
||||||
|
$this->drupalGet('admin/build/modules', array('query' => array("hook_menu_name" => 'changed')));
|
||||||
|
|
||||||
|
$sql = "SELECT menu_name FROM {menu_links} WHERE router_path = 'menu_name_test'";
|
||||||
|
$name = db_result(db_query($sql));
|
||||||
|
$this->assertEqual($name, 'changed', t('Menu name was successfully changed after rebuild.'));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue