How to reproduce:

  1. Create or edit an existing menu item.
  2. Make sure to add a fragment to your path. (ie my/path#fragment)
  3. Save the form, then go back to edit that same menu item.
  4. Remove ONLY the fragment from the link. (ie my/path#fragment becomes my/path)
  5. Save the form. If you edit that item again, the fragment remains in the link path.

How to resolve:
The quickest way to resolve this issue is to modify the menu.admin.inc file in the menu_edit_item_validate function on line 333. Please see below for the updated code.

/**
 * Validate form values for a menu link being added or edited.
 */
function menu_edit_item_validate($form, &$form_state) {
  $item = &$form_state['values']['menu'];
  $normal_path = drupal_get_normal_path($item['link_path']);
  if ($item['link_path'] != $normal_path) {
    drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $item['link_path'], '%normal_path' => $normal_path)));
    $item['link_path'] = $normal_path;
  }
  if (!menu_path_is_external($item['link_path'])) {
    $parsed_link = parse_url($item['link_path']);
    // Unset the query parameter in case the user has not applied one in the new form.
    unset($item['options']['query']);
    if (isset($parsed_link['query'])) {      
      $item['options']['query'] = $parsed_link['query'];
    }
    // Unset the fragment parameter in case the user has not applied one in the new form.
    unset($item['options']['fragment']);
    if (isset($parsed_link['fragment'])) {
      $item['options']['fragment'] = $parsed_link['fragment'];
    }
    if ($item['link_path'] != $parsed_link['path']) {
      $item['link_path'] = $parsed_link['path'];
    }
  }
  if (!trim($item['link_path']) || !menu_valid_path($item)) {
    form_set_error('link_path', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $item['link_path'])));
  }
}

Summary:
The above code simply unsets the query and fragment parameters of the options array so that the user has the ability to remove or add this functionality. The parse_url PHP function call handles identifying whether or not that property needs to be saved and will save it to the $items array regardless, so unsetting the query and fragment parameters is safe.

Comments

dddave’s picture

Status: Active » Needs work

A patch increases the chances of inclusion dramatically. ;)

http://drupal.org/patch/create

reglogge’s picture

Status: Needs work » Closed (duplicate)

I cannot reproduce this behavior. The issue seems to have been fixed here #682784: Once created, menu item query strings can never be deleted. Setting this issue to duplicate.

Please check if you are really running Drupal 6.19.