Download & Extend

Menu items do not inherit their parent's load arguments

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

Title:Local task menu items do not inherit their parents load arguments » Menu items do not inherit their parents load arguments

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

AttachmentSizeStatusTest resultOperations
menu-d6-dev.patch1.31 KBIgnored: Check issue status.NoneNone

#2

Priority:normal» critical
Status:active» needs review

This can lead to some strange bugs when there is a dependency on the load argument. Bumping to critical.

#3

Title:Menu items do not inherit their parents load arguments » Menu items do not inherit their parent's load arguments
Status:needs review» needs work

On a quick code-style review, code comments should begin with a capital letter and end in a period.

#4

Status:needs work» needs review

I have fixed the code comments.

AttachmentSizeStatusTest resultOperations
menu-d6-dev_0.patch1.39 KBIgnored: Check issue status.NoneNone

#5

Priority:critical» normal
Status:needs review» closed (fixed)

No real interest, so closing. It is a good habit to use the general argument map parameters anyway :)

nobody click here