menu_execute_active_handler

Versions
4.6 – 5
menu_execute_active_handler()
6
menu_execute_active_handler($path = NULL)
7
menu_execute_active_handler($path = NULL, $deliver = TRUE)

Execute the page callback associated with the current path.

Parameters

$path The drupal path whose handler is to be be executed. If set to NULL, then the current path is used.

$deliver (optional) A boolean to indicate whether the content should be sent to the browser using the appropriate delivery callback (TRUE) or whether to return the result to the caller (FALSE).

Related topics

▾ 3 functions call menu_execute_active_handler()

comment_permalink in modules/comment/comment.module
Redirects comment links to the correct page depending on comment settings.
drupal_deliver_html_page in includes/common.inc
Package and send the result of a page callback to the browser as a normal HTML page.
user_page in modules/user/user.pages.inc
Access callback for path /user.

Code

includes/menu.inc, line 441

<?php
function menu_execute_active_handler($path = NULL, $deliver = TRUE) {
  if (_menu_site_is_offline()) {
    $page_callback_result = MENU_SITE_OFFLINE;
  }
  else {
    // Rebuild if we know it's needed, or if the menu masks are missing which
    // occurs rarely, likely due to a race condition of multiple rebuilds.
    if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) {
      menu_rebuild();
    }
    if ($router_item = menu_get_item($path)) {
      // hook_menu_alter() lets modules control menu router information that
      // doesn't depend on the details of a particular page request.
      // Here, we want to give modules a chance to use request-time information
      // to make alterations just for this request.
      drupal_alter('menu_active_handler', $router_item, $path);
      if ($router_item['access']) {
        if ($router_item['file']) {
          require_once DRUPAL_ROOT . '/' . $router_item['file'];
        }
        $page_callback_result = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
      }
      else {
        $page_callback_result = MENU_ACCESS_DENIED;
      }
    }
    else {
      $page_callback_result = MENU_NOT_FOUND;
    }
  }

  // Deliver the result of the page callback to the browser, or if requested,
  // return it raw, so calling code can do more processing.
  if ($deliver) {
    $default_delivery_callback = (isset($router_item) && $router_item) ? $router_item['delivery_callback'] : NULL;
    drupal_deliver_page($page_callback_result, $default_delivery_callback);
  }
  else {
    return $page_callback_result;
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.