Maybe this isn't the correct place to be doing this, but in trying to find the earliest possible place to detect a 404, I happened upon hook_page_delivery_callback_alter() from within drupal_delivery_page() in common.inc

This passes in the $delivery_callback so that it can be altered, but if we could also pass in the $page_callback_result, we could detect if we're going to be showing a 404 page (the value being (int) 2) and we could also completely hijack this as well, showing something completely different than a 404.

Why would you want to do this? Well, I'm trying to come up with a module that will instead show a node creation form instead of a 404 page. This is a fairly common wiki practice. If you create a link to a wiki page that doesn't yet exists, you are prompted to create that page.

Again, maybe this is the wrong place to do this, but it would be really convenient.

Comments

chromix’s picture

Seems kind of unnecessary since you could just do something like this:

function MODULE_page_delivery_callback_alter(&$callback) {
  if ($callback == 'drupal_deliver_html_page') {
    $callback = 'MODULE_deliver_html_page';
  }
}

function MODULE_deliver_html_page($page_callback_result) {
  if ($page_callback_result == MENU_ACCESS_DENIED) {
    // do something
  }
  drupal_deliver_html_page($page_callback_result);
}

The boost module does something similar if you're looking for a better example.

devin carlson’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new2.51 KB

This would be useful for the Dialog module.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.