Issue #1007910 by lyricnz, idflood: Fixed D6->D7 update doesn't convert 'primary-links' menu to 'main-menu'.
parent
d48016fcde
commit
09c56b4bfc
|
@ -108,6 +108,58 @@ function menu_update_7000() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename "Primary Links" and "Secondary Links" to their Drupal 7 equivalents.
|
||||
*/
|
||||
function menu_update_7001() {
|
||||
// Migrate D6 menu_primary_links_source to D7 menu_main_links_source (without
|
||||
// renaming).
|
||||
if (variable_get('menu_primary_links_source') !== NULL) {
|
||||
variable_set('menu_main_links_source', variable_get('menu_primary_links_source'));
|
||||
variable_del('menu_primary_links_source');
|
||||
}
|
||||
|
||||
// Rename each menu, and any settings that refer to the old menu name.
|
||||
$rename = array(
|
||||
'primary-links' => array('main-menu', 'Main menu'),
|
||||
'secondary-links' => array('secondary-menu', 'Secondary menu'),
|
||||
);
|
||||
foreach ($rename as $from_menu => $to) {
|
||||
list($to_menu, $to_title) = $to;
|
||||
// Rename the menu, and links in the menu.
|
||||
db_update('menu_custom')
|
||||
->fields(array('menu_name' => $to_menu, 'title' => $to_title))
|
||||
->condition('menu_name', $from_menu)
|
||||
->execute();
|
||||
db_update('menu_links')
|
||||
->fields(array('menu_name' => $to_menu))
|
||||
->condition('menu_name', $from_menu)
|
||||
->execute();
|
||||
|
||||
// Update any content type that used this menu as a default menu.
|
||||
// Note: these variables may be unset/default, in which case we leave them
|
||||
// alone. See menu_update_7000()
|
||||
foreach (_update_7000_node_get_types() as $type => $type_object) {
|
||||
$menu_options = variable_get('menu_options_' . $type);
|
||||
if ($menu_options !== NULL) {
|
||||
variable_set('menu_options_' . $type, str_replace($from_menu, $to_menu, $menu_options));
|
||||
if (variable_get('menu_parent_' . $type) == $from_menu . ':0') {
|
||||
variable_set('menu_parent_' . $type, $to_menu . ':0');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the "source for primary links" and "source for secondary links" to
|
||||
// follow.
|
||||
if (variable_get('menu_main_links_source') == $from_menu) {
|
||||
variable_set('menu_main_links_source', $to_menu);
|
||||
}
|
||||
if (variable_get('menu_secondary_links_source') == $from_menu) {
|
||||
variable_set('menu_secondary_links_source', $to_menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "defgroup updates-7.x-extra"
|
||||
* The next series of updates should start at 8000.
|
||||
|
|
|
@ -7,4 +7,123 @@ db_insert('variable')->fields(array(
|
|||
'name' => 'menu_default_node_menu',
|
||||
'value' => 's:15:"secondary-links";',
|
||||
))
|
||||
->values(array(
|
||||
'name' => 'menu_primary_links_source',
|
||||
'value' => 's:15:"secondary-links";',
|
||||
))
|
||||
->values(array(
|
||||
'name' => 'menu_secondary_links_source',
|
||||
'value' => 's:13:"primary-links";',
|
||||
))
|
||||
->execute();
|
||||
|
||||
// Add some links to the menus.
|
||||
db_insert('menu_links')->fields(array(
|
||||
'menu_name',
|
||||
'mlid',
|
||||
'plid',
|
||||
'link_path',
|
||||
'router_path',
|
||||
'link_title',
|
||||
'options',
|
||||
'module',
|
||||
'hidden',
|
||||
'external',
|
||||
'has_children',
|
||||
'expanded',
|
||||
'weight',
|
||||
'depth',
|
||||
'customized',
|
||||
'p1',
|
||||
'p2',
|
||||
'p3',
|
||||
'p4',
|
||||
'p5',
|
||||
'p6',
|
||||
'p7',
|
||||
'p8',
|
||||
'p9',
|
||||
'updated',
|
||||
))
|
||||
->values(array(
|
||||
'menu_name' => 'navigation',
|
||||
'mlid' => '201',
|
||||
'plid' => '0',
|
||||
'link_path' => 'node/add',
|
||||
'router_path' => 'node/add',
|
||||
'link_title' => 'nodeadd-navigation',
|
||||
'options' => 'a:0:{}',
|
||||
'module' => 'menu',
|
||||
'hidden' => '0',
|
||||
'external' => '0',
|
||||
'has_children' => '1',
|
||||
'expanded' => '0',
|
||||
'weight' => '1',
|
||||
'depth' => '1',
|
||||
'customized' => '0',
|
||||
'p1' => '201',
|
||||
'p2' => '0',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'menu_name' => 'primary-links',
|
||||
'mlid' => '204',
|
||||
'plid' => '0',
|
||||
'link_path' => 'node/add',
|
||||
'router_path' => 'node/add',
|
||||
'link_title' => 'nodeadd-primary',
|
||||
'options' => 'a:0:{}',
|
||||
'module' => 'menu',
|
||||
'hidden' => '0',
|
||||
'external' => '0',
|
||||
'has_children' => '1',
|
||||
'expanded' => '0',
|
||||
'weight' => '1',
|
||||
'depth' => '1',
|
||||
'customized' => '0',
|
||||
'p1' => '204',
|
||||
'p2' => '0',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'menu_name' => 'secondary-links',
|
||||
'mlid' => '205',
|
||||
'plid' => '0',
|
||||
'link_path' => 'node/add',
|
||||
'router_path' => 'node/add',
|
||||
'link_title' => 'nodeadd-secondary',
|
||||
'options' => 'a:0:{}',
|
||||
'module' => 'menu',
|
||||
'hidden' => '0',
|
||||
'external' => '0',
|
||||
'has_children' => '1',
|
||||
'expanded' => '0',
|
||||
'weight' => '1',
|
||||
'depth' => '1',
|
||||
'customized' => '0',
|
||||
'p1' => '205',
|
||||
'p2' => '0',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
|
|
@ -29,16 +29,50 @@ class MenuUpgradePathTestCase extends UpgradePathTestCase {
|
|||
public function testMenuUpgrade() {
|
||||
$this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));
|
||||
|
||||
// Test the migration of "Default menu for content" setting to individual node types.
|
||||
$this->drupalGet("admin/structure/types/manage/page/edit");
|
||||
// Test the migration of "Default menu for content" setting to individual
|
||||
// node types.
|
||||
$this->drupalGet('admin/structure/types/manage/page/edit');
|
||||
$this->assertNoFieldChecked('edit-menu-options-management', 'Management menu is not selected as available menu');
|
||||
$this->assertNoFieldChecked('edit-menu-options-navigation', 'Navigation menu is not selected as available menu');
|
||||
$this->assertNoFieldChecked('edit-menu-options-primary-links', 'Primary Links menu is not selected as available menu');
|
||||
$this->assertFieldChecked('edit-menu-options-secondary-links', 'Secondary Links menu is selected as available menu');
|
||||
$this->assertNoFieldChecked('edit-menu-options-main-menu', 'Main menu is not selected as available menu');
|
||||
$this->assertFieldChecked('edit-menu-options-secondary-menu', 'Secondary menu is selected as available menu');
|
||||
$this->assertNoFieldChecked('edit-menu-options-user-menu', 'User menu is not selected as available menu');
|
||||
$this->assertOptionSelected('edit-menu-parent', 'secondary-links:0', 'Secondary links is selected as default parent item');
|
||||
$this->assertOptionSelected('edit-menu-parent', 'secondary-menu:0', 'Secondary menu is selected as default parent item');
|
||||
|
||||
$this->assertEqual(variable_get('menu_default_node_menu'), NULL, 'Redundant variable menu_default_node_menu has been removed');
|
||||
|
||||
// Verify Primary/Secondary Links have been renamed.
|
||||
$this->drupalGet('admin/structure/menu');
|
||||
$this->assertNoLinkByHref('admin/structure/menu/manage/primary-links');
|
||||
$this->assertLinkByHref('admin/structure/menu/manage/main-menu');
|
||||
$this->assertNoLinkByHref('admin/structure/menu/manage/secondary-links');
|
||||
$this->assertLinkByHref('admin/structure/menu/manage/secondary-menu');
|
||||
|
||||
// Verify the existence of all system-defined (default) menus.
|
||||
foreach (menu_list_system_menus() as $menu_name => $title) {
|
||||
$this->assertLinkByHref('admin/structure/menu/manage/' . $menu_name, 0, 'Found default menu: ' . $title);
|
||||
}
|
||||
|
||||
// Verify a few known links are still present, plus the ones created here.
|
||||
$test_menus = array(
|
||||
'navigation' => array('Add content', 'nodeadd-navigation'),
|
||||
'management' => array('Administration', 'Account settings'),
|
||||
'user-menu' => array('My account', 'Log out'),
|
||||
'main-menu' => array('nodeadd-primary'),
|
||||
'secondary-menu' => array('nodeadd-secondary'),
|
||||
);
|
||||
|
||||
foreach ($test_menus as $menu_name => $links) {
|
||||
$this->drupalGet('admin/structure/menu/manage/' . $menu_name);
|
||||
$this->assertResponse(200, 'Access menu management for ' . $menu_name);
|
||||
foreach ($links as $link_text) {
|
||||
$this->assertLink(t($link_text));
|
||||
}
|
||||
}
|
||||
|
||||
// Check the "source for primary/secondary links" setting.
|
||||
$this->drupalGet('admin/structure/menu/settings');
|
||||
$this->assertOptionSelected('edit-menu-main-links-source', 'secondary-menu');
|
||||
$this->assertOptionSelected('edit-menu-secondary-links-source', 'main-menu');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue