it's seems to be a little bug with inheriting of "page callback" function in hook_menu().
api documentation says:

"page callback": The function to call to display a web page when the user visits the path. If omitted, the parent menu item's callback will be used instead.

If i create menu item like this:

$items['node/add/my_own] = array(
    'title' => t('my link'),
    'access arguments' => array('create node'),
);

"page callback" function should be inherited from menu item with path "node/add" and its node_add function. Which is located in the node.pages.inc file. But error will be occured, because of wrong path to this file is saved in the menu item.
Its happend in file menu.inc.
At line 2320 we are trying to inherit page callback function:

if (!isset($item['page callback']) && isset($parent['page callback'])) {
  $item['page callback'] = $parent['page callback'];
  if (!isset($item['page arguments']) && isset($parent['page arguments'])) {
    $item['page arguments'] = $parent['page arguments'];
  }
  if (!isset($item['file']) && isset($parent['file'])) {
    $item['file'] = $parent['file'];
  }
  if (!isset($item['file path']) && isset($parent['file path'])) {
    $item['file path'] = $parent['file path'];
  }
}

but we cant inherit the file path from parent, because its never be set. at line 2364 we have next code

  if ($item['file']) {
    $file_path = $item['file path'] ? $item['file path'] : drupal_get_path('module', $item['module']);
    $item['include file'] = $file_path .'/'. $item['file'];
  }

this code defines 'include file' and then this data is saved it to the menu_roter table. So because of file path wasn't inferited it is created with drupal_get_path('module', $item['module']); and looks like sites/all/modules/my_own/node.pages.inc. drupal tries to load this file and error is occured.
To prevent this, i found 2 solutions:
1. is to set 'file path' in the menu item

$items['node/add/my_own] = array(
    'title' => t('my link'),
    'access arguments' => array('create node'),
    'file path' => 'modules/node',
);

but in api documentation there is no info about this ability.
and the second is a little upgrade of menu.inc file to force it inherit needed file path.

if ($item['file']) {
  $item['file path'] = $item['file path'] ? $item['file path'] : drupal_get_path('module', $item['module']);
  $item['include file'] = $item['file path'] .'/'. $item['file'];
}

in this case $item['file path'] is set and can be inherited.

CommentFileSizeAuthor
#1 menu.inc_.patch686 bytesDzhumba
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dzhumba’s picture

FileSize
686 bytes

This is the patch to upgrade menu.inc file.

dpearcefl’s picture

Is this still an issue using current Drupal 6?

Status: Needs review » Needs work

The last submitted patch, menu.inc_.patch, failed testing.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.