A site converted from D6 to D7 doesn't have the 'main-menu'. Instead it has 'primary-links'. This might be OK, but there are a couple of anomalies associated with it:

1. There *is* in fact a block created that is the 'main-menu'. However, there *is* no main-menu listed (or in the menu_custom table).
2. D7 modules will probably assume the existence of a 'main-menu' and use it in hook_menu() as a 'default menu', leading to menu items which can appear in a menu block but are part of a menu which does not exist.

Perhaps we should probably convert 'primary-links' to 'main-menu' and do the same with 'secondary-links'.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

EvanDonovan’s picture

Issue tags: +D7 upgrade path

Seems like a good change.

sapox’s picture

Priority: Normal » Major

Exactly, and after the upgrade now I have a site without menu.

The primary-links is in the block list, but I can't assign this to show as a "main-menu" at least in default bartik theme.

rfay’s picture

If your situation is the same as mine was, you'll be able to use the primary-links menu. The problem here was just that so many things assume existence of main-menu. If you don't have a primary-links menu then something different has happened.

sapox’s picture

As far as I know, every single D6 installation used primary-links and secondary-links, which was also my case (although I only used the primary one). But after the upgrade, that primary-link menu is not visible any more, now there is a main-menu in D7, but I have no idea how to move the old primary-links there.

The main-menu is not a region/place to put a block there. And the old primary-link appears now available as a block to put somewhere, but not in the place where the main-menu should be.

All this really confuse me. Why is there no upgrade path for this? I'm lost.

rfay’s picture

So you don't have a primary links menu in the admin/structure/menu? That would be different from my experience.

mlemaitre’s picture

Version: 7.x-dev » 7.0

I have the same problem: I've migrated my site from 6.20 to 7.0. I still have my "primary links" menu, but no "main menu". It is not displayed anywhere.

I tried to manually convert "primary-links" to "main-menu" in my database, but no luck... what can I do to get my menu back ?

montesq’s picture

Version: 7.0 » 7.x-dev

Keep 7.x-dev if this issue is not yet fixed...
I've just closed #939050: Primary link and main menu don't integrate when upgrade from d6 to d7 beta1 as a duplicate.
The user suggested converting manually the menus in the database:

UPDATE {menu_custom} SET menu_name = 'main-menu' WHERE menu_name = 'primary-links';
UPDATE {menu_links} SET menu_name = 'main-menu' WHERE menu_name = 'primary-links';

Maybe it can help you...

rjbrown99’s picture

Yup, +1 to #7.

I just ran this via phpMyAdmin:

UPDATE `menu_custom` SET menu_name = 'main-menu' WHERE menu_name = 'primary-links';
UPDATE `menu_links` SET menu_name = 'main-menu' WHERE menu_name = 'primary-links';
UPDATE `menu_custom` SET menu_name = 'secondary-menu' WHERE menu_name = 'secondary-links';
UPDATE `menu_links` SET menu_name = 'secondary-menu' WHERE menu_name = 'secondary-links';

... and then cleared out my cache. Works for me.

jmbouvier’s picture

Sounds exactly like my problem - I'm in phpMyAdmin but how do I 'run' this?
I'm also missing the Article and Basic Page content types and my existing pages don't allow me to 'Provide a menu link' - is this related?

I upgraded from D6.20 to D7.0 today

PS I'm new to Drupal.org

rjbrown99’s picture

phpMyAdmin -> Click on your database -> Click the SQL tab. Then paste in the queries and hit "Go".

As always I suggest doing a complete backup of your database first if you are not experienced in the ways of SQL. There is an article somewhere on this site that explains how to do phpMyAdmin backups via the export tab.

jmbouvier’s picture

That worked and gave me the 'Provide a menu link' check box that I was missing.

I was slightly confused that the block is called Main menu but the menu in the list of menus is still Primary links.

No matter, it works as I want it now. Thanks for your help.

rjbrown99’s picture

Sorry, forgot to mention that. To be more clear for people that arrive at this issue:

Yes - the end result after the SQL statements is that the underlying menu name in the database changes, but the visual review of this in the admin UI still shows the words "Primary links" and "Secondary links". You will notice that if you visit admin/structure/menu and hover over one of the links (such as "edit menu"), the path is now /admin/structure/menu/manage/main-menu/edit instead of /admin/structure/menu/manage/primary-links/edit.

Also don't forget to clear your cache.

xmacinfo’s picture

I was hit by this bug and find it awkward since I cannot create a main menu or rename the machine primary-links to main-menu with the UI.

Menus have “primary links” and no “main menu” while blocks now have both “primary links” and “main menu” blocks. This is confusing.

We need a proper patch for user upgrading from 6 to 7 without resorting to ask them to run a SQL command.

NaheemSays’s picture

I think the issue may actually be something else - no menu is set as the main menu when upgrading.

If you go to admin/structure/menu/settings you can choose which menu is the main menu and which is the secondary menu, and this seems to be separate from the name of the main menu being "main menu" etc.

(for the source of the main links, choose "primary links" etc in the above mentioned link)

xmacinfo’s picture

@nbz: You may have something here. But I am under the impression that some glue is missing. The upgrade should assign the source menu automatically.

I will look at this again when I will do another upgrade.

xmacinfo’s picture

There is definitely a problem here. When going to admin/structure/menu/settings and applying the correct menu source, it ate my main menu.

The main menu still exist, but it won't show up any more. I'll have to go the SQL route again.

xmacinfo’s picture

I also used a database backup (before issuing the #8 SQL), to no avail. Going to admin/structure/menu/settings and applying the correct menu source still do not display any menu.

So I applied #8 SQL command, cleared the cache and now menus are again displayed.

idflood’s picture

Status: Active » Needs review
FileSize
1.67 KB

Here is an attempt to create a patch for this issue. I've tested this on a fresh d6 site with 5 pages randomly created in primary or secondary menu. It should also fix the block issue described in #13.

xmacinfo’s picture

I have another site to upgrade to D7 and this patch should help. I'll try to do this this weekend.

idflood’s picture

By the way, the patch in #18 should help even if you already updated to d7. Just patch and run update.php instead of using the sql command, it should do the trick.

pillarsdotnet’s picture

Status: Needs review » Needs work

What happens if you already had a "main-menu" or "secondary-menu" in your D6 installation?

idflood’s picture

Status: Needs work » Needs review
FileSize
2.35 KB

#21: I forgot about this possibility. Good catch

So, maybe something like this? ( this should rename the menu only if the target menu-name isn't already defined )

xmacinfo’s picture

Status: Needs review » Reviewed & tested by the community

Finally took time to update a real D6 site to D7 using this patch in #22 before applying the first update.php.

Primary menus are now upgraded properly!

Before that patch, primary and secondary menu would disappear.

xmacinfo’s picture

lyricnz’s picture

Status: Reviewed & tested by the community » Needs work

It's not a duplicate of #761648, but the two are related. That patch migrates the global setting "default menu for new content" to the new per-content-type setting in Drupal 7. However, if you go renaming menus without updating variable 'menu_default_node_menu' (if applicable), then the update in that patch will fail to migrate properly.

lyricnz’s picture

Status: Needs work » Needs review
FileSize
2.67 KB

Here's a patch that updates 'menu_default_node_menu' if required (so that the update in #761648: Menu D6->D7 upgrade doesn't maintain node-menu configuration (f.k.a.: Menu items disappear after upgrade or manual menu entry) will work properly).

lyricnz’s picture

FileSize
3.42 KB

Better still, here's a patch that combines both issues, and uses a loop to rename the blocks+menus.

xmacinfo’s picture

@lyricnz: Thanks for sorting this out. I have been able to migrate my menu D6->D7 with the patch in #22 correctly. As for your patch in #27 (or #26), I cannot test it for now, but I have a site to upgrade to D7.

Also, since you merged both issues in #27, we may mark one issue duplicate of the other. :-)

lyricnz’s picture

Status: Needs review » Needs work

Manual testing failed:

on drupal 6 site

- create a new site in D6:
    drush site-install -y

- drush pm-download devel

- drush pm-enable devel -y

- drush generate-content 10 10

- go to /admin/build/menu-customize/primary-links and add 
  "node1" => node/1
  "node2" => node/2
  "node3" => node/3
- drag "node3" so that it's a sub-menu of node2

- repeat for /admin/build/menu-customize/secondary-links (node 4-6)

- go to /admin/build/menu/add, create mymenu "My Menu". add nodes 1+5+7

- go to /admin/build/menu/settings. Change "default menu for content" to "Secondary Links". Verify primary->primary secondary->secondary.  Save.

- see first screenshot

on drupal 7-devl site, with patch from XX in place

- configure DB to point to D6 database

- run update.php (check for errors)

- go to front page, login - check menu entries are correct

- go to /admin/structure/menu.  verify that this contains primary links, secondary links, and my menu

    Note: this is NOT the same as default setup by D7 (which has main-menu, management, navigation, and user-menu)

   FAIL: menu items were not renamed.  Bug: $count===0 doesn't work, changed to $count==0.  Fix and rerun menu_update_7000()

- go to /admin/structure/menu/settings. verify that main links->primary links, secondary links->secondary links

- go to /admin/structure/types/manage/page select the "menu" tab and verify that secondary links is both selected and default

- go to /admin/structure/menu/settings and check that source for main links and secondary links are set to main menu and secondary menu respectively

  FAIL: warnings emitted

They shouldn't be merged until one is closer to being committed.

lyricnz’s picture

Will post a patch when I get home from work.

xmacinfo’s picture

@lyricnz: I fail to see exactly what you were trying here. For instance, which patch where you trying? #22, #26 or #27?

I was able to consistently loose Primary and Secondary menus from D6->D7 on various D6 installations upgraded to D7. Although in once instance the patch in @22 worked (before #22 was available I used SQL in #8) quite nicely for me, I plan a few other upgrades with real sites to D7. I will use one of the patchs here to review it.

Let me know which one you'd like me to test.

Starminder’s picture

subscribe

xmacinfo’s picture

Priority: Major » Critical

For consistency with the related issue, moving to critical.

lyricnz’s picture

Priority: Critical » Major

The patch in #22 doesn't work because it uses "if($count===0)" :

$count = db_query('SELECT COUNT(*) FROM {block} WHERE delta = :delta', array(':delta' => 'main-menu'))->fetchField();
if ($count === 0) {

The === operator means "identical to and of the same type". But $count is actually a string, not a number - so the comparison is unequal.

The patch in #26 also updates a variable that drupal 6 uses to set a default menu that new content is added to. If we rename "primary-links" to "main-menu", and the default used to be set to "primary-links", then we should update the default to now be "main-menu"

The patch in #27 adds the patch from #761648: Menu D6->D7 upgrade doesn't maintain node-menu configuration (f.k.a.: Menu items disappear after upgrade or manual menu entry), which uses that very same variable. In Drupal 7 this "default menu" is now per-content-type, rather than local; so that part of the patch copies the default into each content type. Patch also uses a loop, rather than repeated code.

lyricnz’s picture

Status: Needs work » Active

I'm having a change of heart on this issue. I don't think we should be moving links between menus, but the old menus should be preserved, along with the settings that select those menus for the "Main links" and "Secondary links". This would preserve the configuration (links shown on the screen etc)

The four default menus (from Drupal 7) should be created however, which would resolve the original issue.

xmacinfo’s picture

@lyricnz: Agreed. I guess we should postpone this issue until #761648: Menu D6->D7 upgrade doesn't maintain node-menu configuration (f.k.a.: Menu items disappear after upgrade or manual menu entry) is solved.

Having two related issues is confusing.

I'll let you postpone or close this issue if you think it's best.

lyricnz’s picture

The issue #761648: Menu D6->D7 upgrade doesn't maintain node-menu configuration (f.k.a.: Menu items disappear after upgrade or manual menu entry) is now fixed and closed. Let's talk about what is the right way to handle the migration of existing menus during the D6->D7 update.

xmacinfo’s picture

@lyricnz: I am running out of sites that needs an upgrade to D7, since I mostly debug upgrades for live sites.

First, I need to confirm that there is still a problem with menu upgrades (in one of my D6->D7 upgrades, the menus were converted correctly).

Do you still see problems when doing upgrades D6->D7?

sun’s picture

Version: 7.x-dev » 8.x-dev
Status: Active » Needs work
Issue tags: +Needs backport to D7
+++ b/modules/block/block.install
@@ -461,5 +461,25 @@ function block_update_7007() {
 /**
+ * Rename primary-links and secondary-links delta to main-menu and secondary-menu.
+ */
+function block_update_7008() {

I'm relatively sure we have at least one call to _block_rehash() in our D7 module updates, and depending on when it is called, all blocks with non-existing deltas will be nuked.

This needs to be double-checked.

+++ b/modules/block/block.install
@@ -461,5 +461,25 @@ function block_update_7007() {
+    $count = db_query('SELECT COUNT(*) FROM {block} WHERE delta = :delta', array(':delta' => $to_menu))->fetchField();
+    if ($count === 0) {
+      db_update('block')
+        ->fields(array('delta' => $to_menu))
+        ->condition('delta', $from_menu)
+        ->execute();

The count query looks completely superfluous to me. Either the old delta is there or not, simply try to update it.

However, the query misses a 'module' condition.

Powered by Dreditor.

rfay’s picture

Version: 8.x-dev » 7.x-dev
Issue tags: -Needs backport to D7

Setting back to 7.x-dev. Unless I'm very confused a 6-to-7 upgrade item doesn't have to be considered for 8.x.

If I'm wrong, that's OK... Just need an explanation of why.

lyricnz’s picture

There are still issues with primary/secondary links during the D6->D7 upgrade. The most obvious is around blocks:
- system.module provides four menu blocks: Navigation, Management, User menu, Main Menu - whether or not these exist
- menu.module provides a block for each "user added" menu, which it determines by subtracting the list above from all the menus in the system.
- this means that "primary links" shows up in the menu module blocks, and a bogus "main menu" block shows up from system.module

The problem happens when a D6 site is upgraded, and menus are not renamed (per current code): system_block_view('main-menu') returns an empty block, since the menu doesn't exist. There may be other, less obvious, effects of the same assumption - which contributed modules could also make.

lyricnz’s picture

FYI:

  • stock D6 has three menus:
    1. Navigation (node/add/* links + others, Site admin links, My Account + Logout)
    2. Primary Links (empty)
    3. Secondary Links (empty)
  • stock D7 has four menus
    1. Navigation (node/add/* links, plus a couple of others)
    2. Main Menu (just a Home link)
    3. Management (Site admin links)
    4. User (My Account + Logout)

So, logically, the old Navigation menu was split into Navigation+Management+User. The old Primary Links is now really the Main Menu, and is used as such by themes. By default D7 uses the User Menu for secondary links, whereas D6 used a custom Secondary Links menu.

Therefore, it seems like the logical upgrade path is:

  1. rename D6 Primary Links menu to D7 Main Menu
    • Update the "source for primary links" and "source for secondary links" to follow, if they were pointing to primary links
    • If "default menu for content" *was* set to the Primary Links (this is the default), it will now have been pushed out to per-content-type settings by menu_update_7000() - see #761648. Need to go update all of those too :/
  2. leave D6 Secondary Links as-is, though it's somewhat orphaned unless it's configured a source of primary/secondary links in the menu settings
  3. create a Management menu, exactly the same as stock D7 install
  4. create a User menu, exactly the same as stock D7 install
  5. don't mess with Navigation menu - a bit tricky.

The tricky bit: should we attempt to "clean up" the old Navigation menu, to remove as-stock menu entries, since they are now in the as-stock User+Management menus?

lyricnz’s picture

FYI the complexity around item #5 above is probably related to #865702: Broken admin pages/links after upgrade if "Administer" was not in the "Navigation" menu. I propose implementing 1-4, then dealing with Navigation menu cleanup as a separate issue.

lyricnz’s picture

Status: Needs work » Needs review
FileSize
6.19 KB

Okay, here's a test that verifies:
- per-node menu settings (from current test)
- that primary-links is renamed to main-menu, including settings that refer to this, and menu links
- that secondary-links is renamed to secondary-menu (for consistency), including settings that refer to this, and menu links
- that all menu management pages can be accessed
- that links placed on these menus are migrated, along with a couple of others

It gets "84 passes, 14 fails, 0 exceptions, and 31 debug messages" here. Fix follows once the testbot verifies.

Status: Needs review » Needs work

The last submitted patch, menu-upgrade-1007910.patch, failed testing.

lyricnz’s picture

Status: Needs work » Needs review
FileSize
8.54 KB

Great. Now here's a patch that fixes all that (includes the tests). It got "2321 passes, 0 fails, 0 exceptions, and 417 debug messages" on the upgrade-path tests.

lyricnz’s picture

FileSize
8.65 KB

Wrap comments at 80 characters, remove line trailing comment. No other change.

catch’s picture

The tests here look great.

lyricnz explained in irc that system module provides menus for the four default system menus - this is separate to whatever menu.module provides for custom menus, so it makes sense to do the renaming here, otherwise blocks/menus can just disappear on upgrade.

I think this is RTBC but I'll leave it overnight for someone else to have a look, or give it one more look over tomorrow if that doesn't happen.

aspilicious’s picture

Status: Needs review » Needs work

The upgrade path looks ok.
The tests are very good.

Note:

+++ b/modules/simpletest/tests/upgrade/upgrade.menu.testundefined
@@ -29,16 +29,50 @@ class MenuUpgradePathTestCase extends UpgradePathTestCase {
-    $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');

Why where these initial upgrade tests using old menu names o_O. That we didn't noticed that at that time. (or maybe it was intentional put there for this issue ;) )

Powered by Dreditor.

lyricnz’s picture

Status: Needs work » Needs review

The existing menu upgrade test was written *before* this fix, which renames those menus. So, without the rename, the old menu still exists, and is therefore a valid choice for the default-parent. So.... the old test worked with the old code.

aspilicious’s picture

Yeah I know it worked with the old code but was just confused why there was a test that needed to be rewritten in the end. But the explanation you gave me in irc made sense a lot of sense :).

aspilicious: there were two issues raised, one for fixing the default-menu-for-content, and one for renaming menus. The first one happened to get in first

I should ask these things in irc before writing them down :p

lyricnz’s picture

Bump. This is still causing issues for users.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Still looks good three weeks later.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 7.x. Thanks so much for the bug fix, and extensive test. Yay!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Frank Ralf’s picture

Status: Closed (fixed) » Needs work

I updated today from 7.4 to 7.7 (which included the patch from this thread) and my former primary links (from a previous 6 installation) disappeared with the following error message:

Notice: Undefined index: primary-links in menu_block_view() (line 462 of [...]\modules\menu\menu.module).

This only happens with the modified Basic 7.x-2.0-rc3 theme I use. Clearing the caches and rebuilding the menus didn't help. The unmodified Basic theme doesn't throw the error, however the menu items created with Taxonomy Menu are missing. Is this related to this thread or to the theme code?

xmacinfo’s picture

Status: Needs work » Closed (fixed)

@Frank Ralf: Please do not reopen a closed issue like this. I suggest you to create a new issue and put a link here for reference, although it looks like you problem is not related.

Frank Ralf’s picture

Sorry for re-opening. There seems to be a new issue already: #1231856: menu_update_7001() breaks when updating from 7.4 or upgrading from D6. And it looks like the issue is indeed update related.