Search code examples
phpdrupaldrupal-7

How to throw 404 error in drupal 7 programmatically without render 2 times?


How to throw 404 error in Drupal 7 programmatically without render 2 times? The 404 page shows two times while calling Drupal code below

return drupal_not_found();

Solution

  • The function drupal_not_found() is meant to be called outside the context of the drupal page delivery system (cf. menu_execute_active_handler()).

    So if you are in a page callback, just

    return MENU_NOT_FOUND;