I just noticed some errors when using some local task menu items with extra load arguments defined. After some investigation, I found that these are generated independently of the parent menu items based on the items "load arguments" and the items defined path.
The attached patch adds a check to allow the menu items to inherit their parents arguments:
The error was generated by the following menu declarations:
<?php
$items['projects/%project/job/%job'] = array(
'title callback' => 'jm_page_title',
'title arguments' => array(3),
'load arguments' => array('%map', '%index'),
'page callback' => 'jm_page_content',
'page arguments' => array('job', 1, 3),
'access arguments' => array('access job management system'),
'type' => MENU_NORMAL_ITEM,
);
$items['projects/%project/job/%job/view'] = array(
'title' => 'View job',
'type' => MENU_DEFAULT_LOCAL_TASK,
// this would prevent the error
// 'load arguments' => array('%map', '%index'),
'weight' => -10,
);
// and one of the load callbacks
function job_load($nid, $map, $index) {
$project = $map[1];
if ($node = node_load(array('nid' => $nid))) {
if ($node->status && $node->type == 'job' && $project->nid = $node->field_project[0]['nid'] && node_access('view', $node)) {
return $node;
}
}
return FALSE;
}
?>
Alan Davison
www.caignwebs.com.au
Comments
Comment #1
alan d. commentedAs I go deeper into this, I've discovered that it is a general menu issue, not just for local task. Updated the patch to reflect this
Comment #2
alan d. commentedThis can lead to some strange bugs when there is a dependency on the load argument. Bumping to critical.
Comment #3
keith.smith commentedOn a quick code-style review, code comments should begin with a capital letter and end in a period.
Comment #4
alan d. commentedI have fixed the code comments.
Comment #5
alan d. commentedNo real interest, so closing. It is a good habit to use the general argument map parameters anyway :)