Posted by David_Rothstein on March 23, 2009 at 3:39am
| Project: | Drupal core |
| Version: | 7.x-dev |
| Component: | update system |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
| Issue tags: | beta blocker, D7 upgrade path |
Issue Summary
The patch that went in at #273137: Split Navigation to User and Administration menu added several new default/required menus to Drupal, but the patch did not contain any update path. The result is that after updating from Drupal 6 to 7, you currently don't have any kind of navigation menu or links to the "Administer" section or much of anything else.
Probably the new menus need to be created, but left empty by default so as to preserve the existing locations of the menu items from the D6 site? Needs more thought...
Comments
#1
How does this look? A lot of things happend in #273137: Split Navigation to User and Administration menu, and I'm not sure I captured all relevant changes in the patch.
#2
#3
I think this needs a little more work - to me this function looks broken also: http://api.drupal.org/api/function/system_update_7009/7
#4
The last submitted patch failed testing.
#5
Reproducing this problem, it makes it rather hard to do upgrade testing from Drupal 6, which is important to keep patches working for the future upgrade.
Regarding the actual patch: the management and navigation menu blocks are now provided by system module, so I don't see why would we need to create the menus here. They seem to be already there. The issue, is that user-block-1 became system-block-navigation and there is this new system-block-management, which nobody enables. The upgrade path migrates user-block-1 to user-block-navigation, which is not true anymore. So we end up without navigation and management blocks.
Manually enabling both blocks after the upgrade gets me the management menu properly (create content + administer), but gets an empty navigation menu (block is not displaying). I bet the later is due to that I did not have any custom nav links, I just did a fresh Drupal 6.11 install to start the upgrade.
So the patch definitely needs work.
#6
In #511258: Do not enable the management menu by default, we are discussing not enabling the management menu block by default, since toolbar module is already there. Once that is resolved, the upgrade path should do the same.
#7
I can only guess this is still an issue. Horrible issue.
#8
.
#9
This patch fixes the user navigation block to the system navigation and changes all 5 default system menus to match what happens on menu_install(). I tested it on a fresh install of D6 upgraded to latest D7 HEAD and it properly configured the menus for me.
#10
The last submitted patch, upgrade-menus.410636.patch, failed testing.
#11
Reroll. Still figuring out patching and git.
#12
Couldn't this use http://api.drupal.org/api/function/menu_save/7 otherwise looks good.
#13
Didn't mean to change status.
#14
Could use http://api.drupal.org/api/function/menu_save/7 for the new menu items but couldn't use it for updating the old menus since we are changing the menu_name entry in the database. If it is important I can switch the few inserts to menu_saves but otherwise I'll leave the patch as is.
#15
Can't use menu_save() because it's a hook_update_N() anyway, RTBC.
#16
It's late, so I might be mis-reading this, but won't this obliterate any custom title/description people may have given to the primary links/secondary links/navigation menu?
I'm not sure the upgrade path should be futzing with those...
#17
No I think you're right, we only want the inserts here.
#18
Re-roll with the db_update('menu_custom) calls removed.
Side note, is it a "feature" that you can not rename a system menu in D7? I just saw that while comparing the edit form/description on D6/D7....
#19
Ups...
#20
#21
Committed to HEAD! Thanks!
#22
+ db_insert('menu_custom')This will not go well if the D6 site had the menu module uninstalled...
#23
And I know that HEAD-to-HEAD is not supported, but I get
The following updates returned messages
system module
Update #7053
* Failed: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'user-menu' for key 'PRIMARY'
when running update.php.
Also, even though this update fails, admin/reports/status still insists that it needs to be done. What is the correct behavior when an update fails? Does it remain "Database updates: Out of date" forever? What's the correct way out of this situation?
#24
The easiest way to prevent that from running is have your own update handler which sets system schema version manually. We may need to add that to head2head.
However I think that's a bug in the patch - if a D6 site happens to have a custom menu with that name, they'll get errors too, so we should do a menu_get_menus() and only create them if they don't already exists instead I think.
#25
I know how to fiddle with the system schema version.... But that doesn't answer the question (perhaps not for this issue): What happens to an end user when an update fails? In D6 (I believe) the update was considered to be "done" even though it failed and was then ignored. In D7 it appears to me that if it fails it's always considered "not done". I think the D7 way is probably better, but we aren't really providing a way for the end user to deal with it.
I should also mention that the failure in #23 is *not* logged to dblog at all, and certainly not with details that would allow it to be debugged. Is that another issue that I should open?EDIT: I see #774882: update.php: errors are not logged#26
Ahh I see, yeah I think the current behaviour is as good as we'll get on that. In this case the upgrade itself has an error, so it not running should result in a fix, which would then allow it to proceed the next time the user updates their site. If the database being upgraded has corrupted behaviour for some reason, then that'd likely take manual intervention before the update could run, I'm not sure there's much else we can do (apart from getting that logging issue committed).
#27
@Gabor in #6 and @David in #22:
Upgrading a Drupal 6 site that had the Navigation men block enabled, and finding no management menu is a pretty big issue. I just test the upgrade path and spent a good minute staring* and thinking about what had happened to all my menu links, before remembering the change. Gabor's comment about the toolbar doesn't apply since no upgraded site will get the toolbar enabled either.
* I may have just been in awe of how smoothly the upgrade went.
#28
Well, as said, we could at least enable the toolbar module on upgrade. We do this with other modules. A notable exception in the D6 upgrade was the update module, but we chose to not enable that automatically, so people can get informed about the types of details it shares with drupal.org. That does not apply here, so we can just go ahead and enable it in the update.
#29
Here is a patch that, as Gábor suggested, enables the toolbar on update.
#30
Nice improvement. RTBC for me
#31
+++ modules/system/system.install 20 Jun 2010 08:37:17 -0000@@ -2415,6 +2415,14 @@ function system_update_7054() {
+ * Enable toolbar module.
+ */
+function system_update_7055() {
+ $module_list = array('toolbar');
+ module_enable($module_list, FALSE);
+}
small patch, code style looks ok.
based on #30, rtbc
59 critical left. Go review some!
#32
Still needs work for #24 - D6 sites may have menus with the same name, and the current update in HEAD fails in that case.
#33
User created menus are prefixed, so such a conflict should be rare or non-existent outside of a head2head scenario.
As catch says in IRC - we just need to make sure they exist - if it's a real problem, we can use a merge query instead of the API function to create them.
#34
After discussion on IRC with catch an pwolanin, the D6 sites with the same name are highly unlikely, as custom menus are prefixed with 'menu-', and the head2head case is currently not supported, so that should not pose a problem.
#35
See #22...
#36
I think all the comments from #22 are addressed in this version:
1) The toolbar module is enabled and so the administrator has access to the menus.
2) Check for table existance. If the table does not exist, the module is not installed; The insertion will occur when the module is enabled.
3) Adding the extra functionality to update_fix_d7_block_deltas() was pretty straight forward
4) The function was indeed incorrect (although it was merely a naming error), but should now be corrected.
Other idea: Would the user and management menu need to be enabled by default if the navigation menu was enabled in D6?
#37
#38
This works well, and created the management menu and enabled the toolbar module. No errors on a site with menu module previously installed.
Now it feels really weird for the site to have toolbar on, overlay off, and not using seven theme :(.
#39
I didn't review carefully but it looks pretty good - however, there is a typo:
+ * mappign the (possibly renamed) block name to the new module name.Also, are we sure that enabling the toolbar is really the right fix here? Compared to (for example) enabling the Management block and putting it in the same region as the Navigation block - that seems like it would be less intrusive. What if they were previously using admin_menu on their D6 site for example... @sun, any thoughts on that? :)
Plus, if we just enable the toolbar module and don't hand out any permissions, then only user 1 can see it; any other admins will still be lost with no easy access to the admin pages. That seems like it's still a big remaining bug to me.
#40
I'll reroll a patch to correct the typo after there is a decision which way to go here:
1) Enable the toolbar => need to hand out permissions: same roles as access administration pages? Might conflict with other "toolbars" such as admin_menu
2) Enable the management menu => looks more like the old situation. Could be in the same region as the navigation menu.
Either way, we should probably enable the menu-user block if the navigation block was previously active. Otherwise normal users can't log themselves out without knowing the path.
Also, in what order should the menu blocks show up?
#41
I really think as long as the person doing the upgrade can find their way to /admin and /user without knowing the URLs, we shouldn't worry too much about the details of the blocks.
When you upgrade a major Drupal version, there is always configuration to change, blocks are a common part of that. In Drupal 5-6 you were lucky if your menu resembled the Drupal 5 one at all.
Having said that, the management block seems like a much less intrusive change if we have to auto-enable something.
#42
#36: 410636-toolbar-and-22.patch queued for re-testing.
#43
The last submitted patch, 410636-toolbar-and-22.patch, failed testing.
#44
A new patch that enables the user-menu and management block on the same places navigation is shown.
#22.2 is fixed in #831732: system_update_7053 needs to check for existence of menu_custom table so that is removed from this patch.
#45
Last patch had some code commented out for testing, but which should be enabled.
edit: I used block_flush_caches because otherwise the user-menu and management block weren't in the block table yet. This could have consequences for other modules who still need to migrate their blocks.
Should the block_flush_caches be replaced by inserting the blocks manually here, or should other modules depend on this update having run already?
#46
+ * Example:
+ * $moved_deltas = array(
+ * 'user' =>
+ * array(
+ * 'navigation' => 'system',
+ * ),
+ * );
There is an @code tag for code in doxygen.
I think we have to use it in this case.
#47
Reroll with code tags added.
#48
The last submitted patch, 410636-with-code-tags.patch, failed testing.
#49
Last patch had ANSI colors in it
#50
forgot to change the status
#51
+++ includes/update.inc 26 Jun 2010 07:25:30 -0000@@ -228,8 +229,21 @@ function update_prepare_d7_bootstrap() {
+ * An associative array. Keys are source module names, values an associative array
+ * mappign the (possibly renamed) block name to the new module name.
Srry that I missed this.
1) line exceeds 80 characters
2) mappign? probably has to be mapping
45 critical left. Go review some!
#52
Rerolled with comments from #51
#53
#52: 410636-fix-comment.patch queued for re-testing.
#54
The last submitted patch, 410636-fix-comment.patch, failed testing.
#55
Added update dependency to make sure the renamed the block tables exist.
#56
add beta blocker tag
#57
+++ includes/update.inc 10 Jul 2010 18:25:12 -0000@@ -252,6 +266,23 @@ function update_fix_d7_block_deltas(&$sa
+ $block_exists = db_query("SELECT COUNT(*) FROM {" . $table . "} WHERE module = :module AND delta = :delta", array(
+ ':module' => $old_module,
+ ':delta' => $delta,
+ ))
+ ->fetchField();
Following lines after $block_exists... need one more level of indentation.
+++ modules/system/system.install 10 Jul 2010 18:25:12 -0000@@ -2419,6 +2425,25 @@ function system_update_7053() {
+ // Show the new menus on themes and places the navigation block is shown
Missing period. Sentence also reads a bit hard for me, but perhaps it's only me.
+++ modules/system/system.install 10 Jul 2010 18:25:12 -0000@@ -2419,6 +2425,25 @@ function system_update_7053() {
+ $blocks = db_query("SELECT theme, status, region, weight, visibility, pages FROM {block} WHERE module = 'system' AND delta = 'navigation'");
...
+ db_update('block')
...
+ ->condition(db_or()->condition('delta', 'user-menu')->condition('delta', 'management'))
+ ->execute();
What happens if the Navigation menu block is not enabled? Do we expect that people have modules/toolbars like admin_menu installed + upgrading them at the same time? I'd be ok with that, just mentioning the possibility.
Powered by Dreditor.
#58
Also the db_or() conditions should be placed on separate lines, one indentation level deeper. Or, probably even better, it should be generated once outside the foreach and then be reused.
Something like
<?php$menu = db_or()
->condition('delta', 'user-menu')
->condition('delta', 'management');
foreach () {
// ....
->condition($menu)
}
?>
#59
Rerolled with comments from sun and Berdir.
I don't think we can't expect people to have modules/toolbars installed, as the upgrade docs say you need to disable all contrib modules/themes before upgrading.
So that only leaves 2 options before the upgrade starts: people having a visible navigation, and people not having visible navigation. Anyway, after the upgrade has ended the navigation visibility will be the same as before. This looks acceptable to me.
#60
RTBC afterwards:
+++ includes/update.inc 12 Jul 2010 06:53:29 -0000
@@ -239,10 +253,10 @@ function update_fix_d7_block_deltas(&$sa
+ ->fetchField();
if ($block_exists) {
@@ -252,6 +266,23 @@ function update_fix_d7_block_deltas(&$sa
+ ->fetchField();
+ if ($block_exists) {
Seems like this DBTNG code exists twice ;)
+++ modules/system/system.install 12 Jul 2010 06:53:30 -0000@@ -1632,6 +1632,17 @@ function system_update_last_removed() {
+}
+/**
Missing blank line.
50 critical left. Go review some!
#61
Another reroll with the comments from #60
#62
#63
I would like to see a summary of this. I see lots of patches and reviews but very little info on the actual problem and solution.
#64
Here are the changes made with this patch:
- includes/update.inc: Allow moving blocks between modules.
- modules/system/system.install:
-- system_update_7004: Move the navigation block from the user to the system module.
-- system_update_7009: Fix the rename of the primary menu variable.
-- system_update_7053: Enable the 'user menu' and 'management' menu blocks on places where the navigation block is shown.
So there are actually three things being fixed in this issue :( Would probably have been better when this patch was splitted up instead of adding everything here.
#65
I think what would be helpful for yoroy (and core committers) are before/after screenshots of the upgrade path with this patch.
#66
There's little to see here. This issue went into different directions before, now we're doing the most simple solution, just ensuring that any previously existing menus and blocks are still displayed (some have been renamed and splitted) after upgrading.
I can't imagine any usability issue derived from this patch, which would require screenshots.
#67
Thx sun for updating the issue title, forgot about it
I've added some screenshots, but there really isn't that much to see here.
#68
Looks good, and I agree that there are no UX implications here. Committed to CVS HEAD. Thanks.
#69
Automatically closed -- issue fixed for 2 weeks with no activity.