Moving the "Administer" menu item breaks pages

webernet - July 15, 2007 - 17:31
Project:Drupal
Version:6.x-dev
Component:menu system
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

Moving the "Administer" menu item out of the Navigation menu breaks a number of pages including /admin, /admin/content, /admin/build, etc.

#1

pwolanin - July 15, 2007 - 17:33

Yes, I've noticed this too. I think the way it is coded is a bit faulty in that it makes assumptions about the depth of the menu links which do not hold if they are moved. So, we need more robust code.

#2

chx - August 28, 2007 - 18:23
Status:active» needs review

Admin! Bad dog! Sit!

AttachmentSizeStatusTest resultOperations
admin_sit.patch4.19 KBIgnoredNoneNone

#3

pwolanin - August 28, 2007 - 18:45
Status:needs review» needs work

no - I think the logic is not good.

don't we need something like:

<?php
  $admin
= db_fetch_array(db_query("SELECT mlid, menu_name FROM {menu_links} WHERE module = 'system' AND link_path = 'admin'"));
 
$result = db_query("
    SELECT *
    FROM {menu_links} ml
    INNER JOIN {menu_router} m ON ml.router_path = m.path
    WHERE ml.link_path like 'admin/%%' AND ml.link_path != 'admin/help' AND ml.plid = %d AND ml.menu_name = '%s' AND hidden = 0
    "
, $admin);
?>

admin may not be in the 'navigation' menu, but there should only be one hook_menu defined instance of this path (right? http://api.drupal.org/api/function/_menu_navigation_links_rebuild/6).

we are only getting items at a single depth right, so there is no need for the ORDER BY. I think there is a sort later.

#4

chx - August 28, 2007 - 19:35
Status:needs work» needs review

I do not think there is a sort of the blocks. Let's see this version.

AttachmentSizeStatusTest resultOperations
admin_sit_0.patch4.45 KBIgnoredNoneNone

#5

chx - August 28, 2007 - 19:51

Um. Maybe this.

AttachmentSizeStatusTest resultOperations
admin_sit_1.patch5.28 KBIgnoredNoneNone

#6

pwolanin - August 28, 2007 - 20:30

Hmmm, now I remember - you want this to be blank if moved out of the navigation menu?

This is wrong no matter what:

ORDER BY p1 ASC, p2 ASC, p3 ASC"

and I still think it should be removed. The array of blocks should get indexed with 50000+weight and title and sorted like links, I think.

#7

pwolanin - August 29, 2007 - 02:59

I still don't like that solution. I think it's enough that the blocks don't show if 'admin' and the blocks are in different menus. Then you can move the blocks out of 'navigation' (or vis-versa) if you want to construct your own custom control panel. Also, changing the weight via menu module ought to affect the bloc ordering or item ordering.

how about this?

AttachmentSizeStatusTest resultOperations
admin_sit_2.patch7.44 KBIgnoredNoneNone

#8

chx - August 29, 2007 - 10:41

plid checking in itself is adequate i think, no need for menu_name checking (as plid is nonzero). also admin/% path checking is not needed, whatever is under administer item is fine.

#9

pwolanin - August 29, 2007 - 12:16

@chx - there is an index on (menu_name, plid) but not just on plid so I think the query would be faster leaving menu_name in the WHERE.

#10

webernet - August 29, 2007 - 13:25
Status:needs review» needs work

The admin pages now work if the 'Administer' menu tree is moved out of 'Navigation' (for example to 'Primary links'). Unfortunately the page titles (and breadcrumbs) are wrong for all of /admin* ("Home").

Also tested moving the 'Administer' menu tree under 'Create content' - everything works fine.

#11

pwolanin - August 29, 2007 - 13:29

@webernet - actually the BC is right - for this reason: The menu system builds the BC based on the 'active' menu (defaults to the Navigation menu). So if you move an item out of the active menu, it will not have an active trail/BC other than "Home". Maybe we should cross-check what happens in D5, but I think it's similar.

#12

pwolanin - August 29, 2007 - 14:25

Ah, apparently the titles are wrong too. However, that's all separate from this issue. Here's the issue I'd been planning to use to tackle these sorts of problems: http://drupal.org/node/155624

#13

pwolanin - August 30, 2007 - 02:56
Status:needs work» needs review

ok, I think this addresses problems with the previous patch in terms of queries and descriptions.

AttachmentSizeStatusTest resultOperations
admin_sit_3.patch7.73 KBIgnoredNoneNone

#14

webernet - August 30, 2007 - 19:42
Status:needs review» reviewed & tested by the community

Moving the administer menu tree around under navigation works fine.
Moving the administer menu tree out of navigation works, but the page titles are all 'Home'.

Assuming the page title issue will be addressed in another patch, this one is working properly and is ready to go.

Rerolled to remove whitespace changes which were already committed and added periods to two comments.

AttachmentSizeStatusTest resultOperations
admin_sit_4.patch4.8 KBIgnoredNoneNone

#15

Gábor Hojtsy - September 1, 2007 - 06:55
Status:reviewed & tested by the community» needs work

It would be great to document, why the 50000+ sorting weight is required. What does it need to be after?

#16

pwolanin - September 1, 2007 - 12:51

@Gabor - in both places I added have this code comment:

// Prepare for sorting as in function _menu_tree_check_access().

since there is a detailed explanation in that function - do we also need a detailed explanation here?

#17

Gábor Hojtsy - September 1, 2007 - 13:56

Erm, a short doc would be great there.

#18

pwolanin - September 1, 2007 - 14:19
Status:needs work» needs review

ok, added additional code comments.

AttachmentSizeStatusTest resultOperations
admin_sit_5.patch4.9 KBIgnoredNoneNone

#19

chx - September 1, 2007 - 14:35
Status:needs review» reviewed & tested by the community

Ample comments. Functionality same as the one webernet tested.

#20

Gábor Hojtsy - September 1, 2007 - 14:42
Status:reviewed & tested by the community» fixed

Thanks for the update, committed!

#21

Anonymous - September 15, 2007 - 14:51
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.