Posted by Alan D. on October 4, 2008 at 5:52am
| Project: | Drupal core |
| Version: | 6.x-dev |
| Component: | menu system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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
#1
As 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
#2
This can lead to some strange bugs when there is a dependency on the load argument. Bumping to critical.
#3
On a quick code-style review, code comments should begin with a capital letter and end in a period.
#4
I have fixed the code comments.
#5
No real interest, so closing. It is a good habit to use the general argument map parameters anyway :)