After upgrade from Drupal 4.6 to 4.7 Beta 2, primary and secondary links do not display anymore. Adding items to the new primary and secondary menus (?q=admin/settings/menu) DO NOT help either.

The solution is to get the menu id's from administer->settings->menus, and run the following PHP code:

variable_set('menu_primary_menu', 133);
variable_set('menu_secondary_menu', 134);

Best regards.

Frank

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Richard Archer’s picture

The update script is supposed to copy links from the theme into the menu and only if some items were copied it sets those variable.

So, the obvious question... were links copied into the menu correctly?

admin/settings/menu also provides an interface for setting those variables.

naudefj’s picture

Thank you very much for the reply! The update script did not copy any links from my theme into the menu.

After the update the "variable" table still contains exactly the same values for "phptemplate_primary_links" and "phptemplate_secondary_links".

Richard Archer’s picture

That's because the update script looks for variables 'primary_links' and 'secondary_links'.

Can you see how your variables got 'phptemplate_' prepended? I can't see how that can happen... or how the links could work if it did!

naudefj’s picture

Now, that is a very good question. Probably because I'm using a PHP template with Drupal 4.6. Does the update procedure cater for both phptemplate and xtemplate themes?

Anyway, searching for 'phptemplate_primary_links' on Google returns about 99 links, so other people may have the same problem.

Richard Archer’s picture

Priority: Normal » Critical
Status: Active » Needs review
FileSize
4.24 KB

Here's a patch to update.inc that does a better job of importing links. I'm upping the issue status to critical because the current update script loses the links in a number of situations. Even if this version still has problems it has to be an improvement!

It still won't import xtemplate links which are stored as a string... but it now leaves them in the theme_settings variable so they can be recovered if needed.

Difficult patch to test, this one. Nearly sent me mad debugging it! I hope someone volunteers to review it :)

naudefj’s picture

Status: Needs review » Reviewed & tested by the community

+1

After applying your patch, my primary and secondary links were successfully migrated to Drupal 4.7 beta2.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)
naudefj’s picture

Version: » 4.7.0-beta3
Status: Closed (fixed) » Active

This problem is back in Drupal 4.7 beta 3. Looks like some changes were committed after this patch that broke the primary and secondary links upgrade again.

Richard Archer’s picture

It's funny how the upgrade script has caused more problems than the actual patch!

This patch: http://cvs.drupal.org/viewcvs/drupal/drupal/database/updates.inc?r1=1.17... should not have changed the way phptemplate links are imported... it only effects way the theme_settings variable is processed.

What the upgrade script does is:

gets the phptemplate_primary_links variable
gets the phptemplate_primary_links_more variable
if theme_settings['primary_links'] is an array, gets it
if theme_settings['primary_links'] is not an array, parses links from xtemplate format

It then merges these all together and adds the links to the primary links menu. And repeats for secondary links.

I don't see how this process could fail... provided all the links are in the expected variables.

Could you perhaps email me a dump of the variables table from your 4.6 database?
drupal.org@juggernaut.com.au

Richard Archer’s picture

Status: Active » Needs review
FileSize
900 bytes

OK, I've had a look at this and it looks like the data should be imported correctly but that under some circumstances (php_template has the links toggle on but theme settings has it off) the new primary links variables won't be set up correctly. I seem to recall another issue raised which had a similar problem.

I'm not sure how to go about fixing this... it's hard to know whether to look at the theme_settings toggle or the phptemplate settings toggle... and there could be several different phptemplate settings, one for each installed theme!

It might be best to ignore the toggles and just display the links if any menu items were imported. Some users may need to go to admin/settings/menu and disable the new links.

The attached patch does that.

Richard Archer’s picture

Addition to patch: fixes some warnings when the variable phptemplate_primary_links_more is a string.

Dries’s picture

Status: Needs review » Fixed

Committed to HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)
joel_guesclin’s picture

Version: 4.7.0-beta3 » 4.7.0-rc3
Status: Closed (fixed) » Active

I have just done an upgrade using a test database from 4.6.2 to 4.7.0-rc3. My theme is a phptemplate theme (based on box-grey) with several primary and secondary links defined. I thought from this thread that the problem had been resolved, but apparently not since after upgrading I have lost all my links.
Since I have multiple sites to maintain, all of which make extensive use of both primary and secondary links, this is a major issue for me - and it seems to me that since PHPtemplate has become the standard templating engine for Drupal it should certainly support moving the links during the upgrade (that was one reason I switched to a phptemplate theme in 4.6).
A more minor issue is that the default URL associated with the default "edit primary links" appears to be broken: it is "http://localhost/drupal-4.7.0/%3Fq%3Dadmin/themes/settings%22+class%3D%2..."

Gerhard Killesreiter’s picture

I've updated a 4.6.x test database to CVS head and cannot reproduce the issue.

I did the following:

install 4.6 phptemplate
install 4.6 box_grey
create primary and secondary links
switch back to bluemarine
update
result:
All links got properly migrated

tenrapid’s picture

To reproduce do the following:

- install 4.6 drupal, phptemplate, box_grey
- go to admin/themes/settings/box_grey
- create primary/secondary links there
- update
-> the phptemplate specific links are gone

tenrapid’s picture

Component: menu system » update system
Status: Active » Needs work
FileSize
1.5 KB

Here is a first try.

Responsible for the issue is this line in system_update_151()
$links = array_merge($phptemplate_links, $phptemplate_links_more, $theme_links);

Both arrays $phptemplate_links and $theme_links have the keys 'text' and 'link'. So the phptemplate links are overwritten. $phptemplate_links_more is bogus since it's only a helper variable.

tenrapid’s picture

Slightly changed.

adrian’s picture

That is correct.

phptemplate_links_more is completely bogus.

it was the checkbox underneath the textfield grid that allowed you to get more fields.

I support tenrapid's patch.

Gerhard Killesreiter’s picture

Status: Needs work » Fixed

applied

Richard Archer’s picture

Thanks guys, I thougt there was something fishy with that code.
This solution looks sound and works for me.

Good work!

Anonymous’s picture

Status: Fixed » Closed (fixed)