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
CommentFileSizeAuthor
#4 menu-d6-dev_0.patch1.39 KBalan d.
#1 menu-d6-dev.patch1.31 KBalan d.

Comments

alan d.’s picture

Title: Local task menu items do not inherit their parents load arguments » Menu items do not inherit their parents load arguments
StatusFileSize
new1.31 KB

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

alan d.’s picture

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.

keith.smith’s picture

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.

alan d.’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB

I have fixed the code comments.

alan d.’s picture

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 :)