Commit 36669878 authored by webchick's avatar webchick
Browse files

Issue #594660 follow-up by sun: Fixes for upgrade path for rename default menu names.

parent 968df7e2
......@@ -323,6 +323,36 @@ function block_update_8003() {
);
}
/**
* Rename default menu names.
*/
function block_update_8004() {
// System menu's new block deltas are prefixed with 'menu-'.
$map = array(
'navigation' => 'menu-tools',
'management' => 'menu-admin',
'user-menu' => 'menu-account',
'main-menu' => 'menu-main',
);
foreach ($map as $old => $new) {
db_update('block')
->condition('module', 'system')
->condition('delta', $old)
->fields(array('delta' => $new))
->execute();
db_update('block_language')
->condition('module', 'system')
->condition('delta', $old)
->fields(array('delta' => $new))
->execute();
db_update('block_role')
->condition('module', 'system')
->condition('delta', $old)
->fields(array('delta' => $new))
->execute();
}
}
/**
* @} End of "addtogroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
......
......@@ -322,7 +322,7 @@ function testBlock() {
// Select the Administration menu block to be configured and moved.
$block = array();
$block['module'] = 'system';
$block['delta'] = 'admin';
$block['delta'] = 'menu-admin';
$block['title'] = $this->randomName(8);
// Set block title to confirm that interface works and override any custom titles.
......
......@@ -128,7 +128,7 @@ function contextual_preprocess(&$variables, $hook) {
* menu_contextual_links(). For example:
* @code
* array('#contextual_links' => array(
* 'block' => array('admin/structure/block/manage', array('system', 'tools')),
* 'block' => array('admin/structure/block/manage', array('system', 'menu-tools')),
* 'menu' => array('admin/structure/menu/manage', array('tools')),
* ))
* @endcode
......
......@@ -691,6 +691,26 @@ function node_update_8007() {
}
}
/**
* Rename default menu names.
*/
function node_update_8008() {
// System menu's new block deltas are prefixed with 'menu-'.
$map = array(
'navigation' => 'menu-tools',
'management' => 'menu-admin',
'user-menu' => 'menu-account',
'main-menu' => 'menu-main',
);
foreach ($map as $old => $new) {
db_update('block_node_type')
->condition('module', 'system')
->condition('delta', $old)
->fields(array('delta' => $new))
->execute();
}
}
/**
* @} End of "addtogroup updates-7.x-to-8.x"
* The next series of updates should start at 9000.
......
......@@ -46,7 +46,7 @@ function setUp() {
'status' => 1,
))
->condition('module', 'system')
->condition('delta', 'tools')
->condition('delta', 'menu-tools')
->execute();
}
......@@ -354,7 +354,7 @@ function testBreadCrumbs() {
// ('taxonomy/term/%') should never be translated and appear in any menu
// other than the breadcrumb trail.
$elements = $this->xpath('//div[@id=:menu]/descendant::a[@href=:href]', array(
':menu' => 'block-system-tools',
':menu' => 'block-system-menu-tools',
':href' => url($link['link_path']),
));
$this->assertTrue(count($elements) == 1, "Link to {$link['link_path']} appears only once.");
......
......@@ -45,7 +45,7 @@ function setUp() {
db_merge('block')
->key(array(
'module' => 'system',
'delta' => 'tools',
'delta' => 'menu-tools',
'theme' => 'bartik',
))
->fields(array(
......
......@@ -43,7 +43,7 @@ function setUp() {
'status' => 1,
))
->condition('module', 'system')
->condition('delta', 'tools')
->condition('delta', 'menu-tools')
->execute();
// This test puts menu links in the Administration menu and then tests for
......@@ -56,7 +56,7 @@ function setUp() {
'status' => 1,
))
->condition('module', 'system')
->condition('delta', 'admin')
->condition('delta', 'menu-admin')
->execute();
}
......
......@@ -43,6 +43,16 @@ public function testFilledStandardUpgrade() {
$this->drupalGet('');
$this->assertResponse(200);
// Verify that the former Navigation system menu block appears as Tools.
$this->assertText(t('Tools'));
// Verify that the Account menu still appears as secondary links source.
$this->assertText(t('My account'));
$this->assertText(t('Log out'));
// Verify the the Main menu still appears as primary links source.
$this->assertLink(t('Home'));
// Verify that we are still logged in.
$this->drupalGet('user');
$this->clickLink(t('Edit'));
......
......@@ -2515,11 +2515,13 @@ function system_block_info() {
'status' => 1,
);
// System-defined menu blocks.
// The block deltas need to be prefixed with 'menu-', since the 'main' menu
// would otherwise clash with the 'main' page content block defined above.
foreach (menu_list_system_menus() as $menu_name => $title) {
$blocks[$menu_name]['info'] = t($title);
$blocks['menu-' . $menu_name]['info'] = t($title);
// Menu blocks can't be cached because each menu item can have
// a custom access callback. menu.inc manages its own caching.
$blocks[$menu_name]['cache'] = DRUPAL_NO_CACHE;
$blocks['menu-' . $menu_name]['cache'] = DRUPAL_NO_CACHE;
}
return $blocks;
}
......@@ -2546,6 +2548,8 @@ function system_block_view($delta = '') {
$block['content'] = menu_get_active_help();
return $block;
default:
// Strip off 'menu-' prefix from block delta.
$delta = substr($delta, 5);
// All system menu blocks.
$system_menus = menu_list_system_menus();
if (isset($system_menus[$delta])) {
......
......@@ -28,7 +28,7 @@ function minimal_install() {
),
array(
'module' => 'system',
'delta' => 'tools',
'delta' => 'menu-tools',
'theme' => $default_theme,
'status' => 1,
'weight' => 0,
......@@ -38,7 +38,7 @@ function minimal_install() {
),
array(
'module' => 'system',
'delta' => 'management',
'delta' => 'menu-admin',
'theme' => $default_theme,
'status' => 1,
'weight' => 1,
......
......@@ -110,7 +110,7 @@ function standard_install() {
),
array(
'module' => 'system',
'delta' => 'tools',
'delta' => 'menu-tools',
'theme' => $default_theme,
'status' => 1,
'weight' => 0,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment