So I'm not sure how to describe this, but this is a bug in D6 that I'm fairly sure is in D7, too. Thanks to ghoti for getting bitten by it. :-)

The new menu system allows a menu item to specify an extra include file, and a path in which that file exists. If not specified, the file and path will inherit from a parent menu item, specifically the same one that defines the page callback. That's all well and good, *except* if the parent menu item is in a different module. In that case, the "file path" key defaults to the module of the child menu item, not the parent menu item, and so is incorrect.

I am assigning this to myself as a reminder that I need to fix this, although if someone else wants to do so first I won't complain. :-) The temporary workaround is to explicitly define file and file path in the child menu item, so that they won't inherit buggily.

Comments

Crell’s picture

Version: 7.x-dev » 6.2

Actually since the registry patch is going to change that logic anyway and is RTBC, I am setting this back to D6 as it's not worth fixing in D7 when it's about to get rewritten anyway.

dropcube’s picture

Version: 6.2 » 6.x-dev
Assigned: Crell » dropcube
Status: Active » Needs review
StatusFileSize
new1.53 KB

Crell: The bug seems to be because of an incorrect 'if' statement and wrong variable assignment.

This patch fixes it.

dropcube’s picture

StatusFileSize
new910 bytes

Well, after an IRC chat with chx, the only problem here is the wrong variable name:

dropcube: chx: so 'page callback' and others are inherited as a whole ?
chx: usually yes
chx: the rule is this
chx: page callback, argument, file and file path is a package
chx: you inherit the whole package
chx: if you do not define page callback
chx: but, if you want to be more specific you can , so you override everything once inherit fires
chx: but if page callback is not inherited, there is no inheritance at all.
chx: page callback somehow "carries" the whole package with itself
chx: that's quite logical, isn't it?
chx: most of the time you want to override page arguments for a sub page and nothing else.

This new patch fixes this.

dropcube’s picture

StatusFileSize
new909 bytes

Re-rolling the patch against the 6.x branch.

pasqualle’s picture

StatusFileSize
new907 bytes

reroll

bmarcotte’s picture

re #4

Hi Dropcube,
Thanks for the patch. I was having this problem as well. The patch line numbers are no longer valid, so I manually patched my file. The version I have is '$Id: menu.inc,v 1.255.2.32 2009/10/06 11:59:05 goba Exp $' The current line numbers are 2423 and 2424.

All is working now

Bob

bmarcotte’s picture

Folks should note that the file's path should be placed in an array element 'file path' i.e.:

   $items['user/%user/galleries'] = array(
    'title' => 'My Galleries',
    //'title callback' => 'node_gallery_list_title',
    //'title arguments' => array(1),
    'page callback' => 'node_gallery_list',
    'page arguments' => array(1),
    'access arguments' => array(NODE_GALLERY_PERM_VIEW_GALLERY),
    'file path' => 'sites/all/modules/node_gallery',
    'file' => 'node_gallery.pages.inc',
    'type' => MENU_LOCAL_TASK,
  );

this was not ovbious to me....I think I have it right now

Bob

pasqualle’s picture

Version: 6.x-dev » 7.x-dev
Assigned: dropcube » Unassigned
StatusFileSize
new825 bytes

Status: Needs review » Needs work

The last submitted patch, D7-248173-8-menu_file_path.patch, failed testing.

pasqualle’s picture

Status: Needs work » Needs review

#8: D7-248173-8-menu_file_path.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, D7-248173-8-menu_file_path.patch, failed testing.

pasqualle’s picture

Status: Needs work » Needs review
StatusFileSize
new845 bytes
ff1’s picture

#12: D7-248173-12-menu_file_path.patch queued for re-testing.

pasqualle’s picture

Status: Needs review » Closed (duplicate)