D4.6.8 to D6.10: Secondary Menu not Working

When I upgraded from D4.6 to D6.10, I noticed that secondary menus weren't showing up. I assumed I had just forgotten to turn something on so I didn't worry about it. Upon upgrading another installation from D4.6 to D6.11, I realized that secondary menus weren’t showing on the second upgrade either. This meant I needed to investigate further. To make a long story short, the variable table had the wrong value for menu_secondary_links_source. To know what this means and how I came to this conclusion, please read the process below.
Basic Verification Process
When I discovered that the secondary menu was not showing up, I first looked at the various settings required to make the menu work.

  • Check the Theme - Make sure the theme in use has been programmed to show a secondary menu. You can determine this several ways. One way is to open page.tpl.php in a text editor and do a search for "$secondary_links." If you don't find it, the theme will not show the secondary menu. If you do, carry on to the next step.
  • Create Menu Item - Assign a menu item to the secondary menu via admin > site building > menus. Themes are typically configured not to show the secondary menu area unless an item has been assigned to the menu.
  • Turn on Secondary Menus - Verify that the theme configuration is set to show the secondary menu via admin > site building > themes > configure. There are two places where secondary menus can be set, in global settings and in the configuration settings for the specific theme.
  • Check other Themes - When one theme doesn't show the secondary menu, try another, so you can rule out a potential theme issue versus another type of issue. Garland is one of Drupal’s default themes and is set to show secondary menus. This is a good testing option.

After performing these processes, I took testing to another level.
Other Testing Processes
I am lucky because I have several sites in various states that allow me to compare configurations and assess what is different about one site versus another. This comparison option is at the core of the testing steps listed below.

  • Check other Sites - Open another site using the same installation of Drupal and a different database. Enable a secondary menu and see if it works. If it does, the problem probably isn't the installation of Drupal. In my case, the sites I had created after upgrading the Drupal installation to D6 were operating correctly.
  • Check the Theme Variables - The next step was to pick a theme, open the page.tpl.php and replace $secondary_links with $primary_links to determine if the theme was failing due to the value of the variable or whether is was something else. The menu bar for the secondary menu appeared on the screen with the primary menu links showing. Conclusion, the theme was fine. $secondary_links was the problem, it wasn’t getting assigned a value. Why?
  • Check the Database - Remember, the Drupal installation works, the theme works, the only difference between the site with issues and the other sites that worked is the database. What data is used to ultimately assign a value to $secondary_links? I reached out to the developers on the #Drupal IRC and was guided to http://api.drupal.org/api/function/template_preprocess_page/6 (thank you Heine), which led me to http://api.drupal.org/api/function/menu_secondary_links/6 where it showed this line of code: if (variable_get('menu_secondary_links_source', 'secondary-links') == variable_get('menu_primary_links_source', 'primary-links')) { . I went hunting in the database for menu_secondary_links_source and secondary-links. I confirmed that the menu table contained an item called secondary-links so there was data to be had. I then looked for menu_secondary_links_source in the variable table and that’s when I found the problem. This variable had been set to s:0:""; when it should have been s:15:"secondary-links";. I updated the database to the correct value, ran cron.php, and that’s what fixed it.

Observation About menu_secondary_links_source
In my investigation, I discovered that the sites that I had set up after the upgrade, didn’t have menu_primary_links_source or menu_secondary_links_source variables and they showed the secondary menu just fine. I wonder why? Also, the original D4 database didn’t have these variables either. So where did it come from and why aren’t they present in each database? If I ever find out, I will update this article.
Also, this issue was present in two of three D4 site upgrades. Only one of the three was working. Luckily, it had the correct value for the menu_secondary_links_source variable. If it hadn’t I would have been back on the IRC asking for tips on how to find the correct value.
When something doesn’t work, keep digging. The forum issue I opened when I was starting my investigation is located at http://drupal.org/node/472362. I posted it when I realized that the variable value wasn’t being set right. A summary of what is here is included. When you find the answer to your issue, please share it so we can all learn from your triumphs.