_menu_delete_item

  1. drupal
    1. 6
    2. 8
    3. 7
Versions
6 – 7 _menu_delete_item($item, $force = FALSE)

Helper function for menu_link_delete; deletes a single menu link.

Parameters

$item Item to be deleted.

$force Forces deletion. Internal use only, setting to TRUE is discouraged.

Related topics

▾ 3 functions call _menu_delete_item()

menu_delete_links in includes/menu.inc
Deletes all links for a menu.
menu_link_delete in includes/menu.inc
Delete one or several menu links.
_menu_navigation_links_rebuild in includes/menu.inc
Helper function to build menu links for the items in the menu router.

Code

includes/menu.inc, line 2950

<?php
function _menu_delete_item($item, $force = FALSE) {
  $item = is_object($item) ? get_object_vars($item) : $item;
  if ($item && ($item['module'] != 'system' || $item['updated'] || $force)) {
    // Children get re-attached to the item's parent.
    if ($item['has_children']) {
      $result = db_query("SELECT mlid FROM {menu_links} WHERE plid = :plid", array(':plid' => $item['mlid']));
      foreach ($result as $m) {
        $child = menu_link_load($m->mlid);
        $child['plid'] = $item['plid'];
        menu_link_save($child);
      }
    }

    // Notify modules we are deleting the item.
    module_invoke_all('menu_link_delete', $item);

    db_delete('menu_links')->condition('mlid', $item['mlid'])->execute();

    // Update the has_children status of the parent.
    _menu_update_parental_status($item);
    menu_cache_clear($item['menu_name']);
    _menu_clear_page_cache();
  }
}
?>