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

8.0.x
webchick 2012-10-26 09:07:34 -07:00
parent 968df7e295
commit 366698784c
11 changed files with 76 additions and 12 deletions

View File

@ -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.

View File

@ -322,7 +322,7 @@ class BlockTest extends WebTestBase {
// 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.

View File

@ -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

View File

@ -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.

View File

@ -46,7 +46,7 @@ class BreadcrumbTest extends MenuTestBase {
'status' => 1,
))
->condition('module', 'system')
->condition('delta', 'tools')
->condition('delta', 'menu-tools')
->execute();
}
@ -354,7 +354,7 @@ class BreadcrumbTest extends MenuTestBase {
// ('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.");

View File

@ -45,7 +45,7 @@ class RouterTest extends WebTestBase {
db_merge('block')
->key(array(
'module' => 'system',
'delta' => 'tools',
'delta' => 'menu-tools',
'theme' => 'bartik',
))
->fields(array(

View File

@ -43,7 +43,7 @@ class TrailTest extends MenuTestBase {
'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 @@ class TrailTest extends MenuTestBase {
'status' => 1,
))
->condition('module', 'system')
->condition('delta', 'admin')
->condition('delta', 'menu-admin')
->execute();
}

View File

@ -43,6 +43,16 @@ class FilledStandardUpgradePathTest extends UpgradePathTestBase {
$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'));

View File

@ -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])) {

View File

@ -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,

View File

@ -110,7 +110,7 @@ function standard_install() {
),
array(
'module' => 'system',
'delta' => 'tools',
'delta' => 'menu-tools',
'theme' => $default_theme,
'status' => 1,
'weight' => 0,