diff --git a/core/includes/common.inc b/core/includes/common.inc index 29f1ef1..3706049 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -699,18 +699,6 @@ function drupal_site_offline() { } /** - * Delivers a "page not found" error to the browser. - * - * Page callback functions wanting to report a "page not found" message should - * return MENU_NOT_FOUND instead of calling drupal_not_found(). However, - * functions that are invoked in contexts where that return value might not - * bubble up to menu_execute_active_handler() should call drupal_not_found(). - */ -function drupal_not_found() { - throw new NotFoundHttpException(); -} - -/** * Delivers an "access denied" error to the browser. * * Page callback functions wanting to report an "access denied" message should @@ -2354,8 +2342,7 @@ function l($text, $path, array $options = array()) { * Delivers a page callback result to the browser in the appropriate format. * * This function is most commonly called by menu_execute_active_handler(), but - * can also be called by error conditions such as drupal_not_found(), - * drupal_access_denied(), and drupal_site_offline(). + * can also be called by error conditions such as drupal_site_offline(). * * When a user requests a page, index.php calls menu_execute_active_handler(), * which calls the 'page callback' function registered in hook_menu(). The page diff --git a/core/includes/file.inc b/core/includes/file.inc index f6cab86..3a0a68b 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -1997,7 +1997,7 @@ function file_transfer($uri, $headers) { * modules returned headers the download will start with the returned headers. * If a module returns -1 drupal_access_denied() will be returned. If the file * exists but no modules responded drupal_access_denied() will be returned. - * If the file does not exist drupal_not_found() will be returned. + * If the file does not exist a NotFoundHttpException() will be thrown. * * @see hook_file_download() * @see system_menu() diff --git a/core/modules/book/book.pages.inc b/core/modules/book/book.pages.inc index aedde16..c00fb6f 100644 --- a/core/modules/book/book.pages.inc +++ b/core/modules/book/book.pages.inc @@ -6,6 +6,7 @@ */ use Drupal\node\Node; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Page callback: Prints a listing of all books. @@ -53,7 +54,7 @@ function book_export($type, $nid) { } else { drupal_set_message(t('Unknown export format.')); - drupal_not_found(); + throw new NotFoundHttpException(); } } @@ -84,7 +85,7 @@ function book_export_html($nid) { return theme('book_export_html', array('title' => $node->title, 'contents' => $contents, 'depth' => $node->book['depth'])); } else { - drupal_not_found(); + throw new NotFoundHttpException(); } } else { diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index 9eabe13..4329492 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -6,6 +6,7 @@ */ use Drupal\comment\Comment; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Page callback: Presents an administrative comment listing. @@ -260,7 +261,7 @@ function comment_confirm_delete_page($cid) { if ($comment = comment_load($cid)) { return drupal_get_form('comment_confirm_delete', $comment); } - drupal_not_found(); + throw new NotFoundHttpException(); } /** diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 58ea4a6..4fa8fee 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -10,6 +10,7 @@ */ use Drupal\node\Node; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Comment is awaiting approval. @@ -506,7 +507,7 @@ function comment_permalink($cid) { $_GET['page'] = $page; return menu_execute_active_handler('node/' . $node->nid, FALSE); } - drupal_not_found(); + throw new NotFoundHttpException(); } /** diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc index 2986d13..39b8a24 100644 --- a/core/modules/comment/comment.pages.inc +++ b/core/modules/comment/comment.pages.inc @@ -6,6 +6,7 @@ */ use Drupal\node\Node; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Form constructor for the comment reply form. @@ -122,5 +123,5 @@ function comment_approve($cid) { drupal_set_message(t('Comment approved.')); drupal_goto('node/' . $comment->nid); } - drupal_not_found(); + throw new NotFoundHttpException(); } diff --git a/core/modules/contact/contact.pages.inc b/core/modules/contact/contact.pages.inc index bf096a7..a1c2926 100644 --- a/core/modules/contact/contact.pages.inc +++ b/core/modules/contact/contact.pages.inc @@ -5,6 +5,8 @@ * Page callbacks for the Contact module. */ +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + /** * Form constructor for the site-wide contact form. * @@ -41,8 +43,7 @@ function contact_site_form($form, &$form_state) { drupal_set_message(t('The contact form has not been configured. Add one or more categories to the form.', array('@add' => url('admin/structure/contact/add'))), 'error'); } else { - drupal_not_found(); - drupal_exit(); + throw new NotFoundHttpException(); } } diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index c124b9e..8fe85be 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -5,6 +5,8 @@ * Administration functions for language.module. */ +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + /** * User interface for the language overview screen. */ @@ -375,8 +377,7 @@ function language_admin_delete_form($form, &$form_state, $language) { $languages = language_list(); if (!isset($languages[$langcode])) { - drupal_not_found(); - drupal_exit(); + throw new NotFoundHttpException(); } else { $form['langcode'] = array('#type' => 'value', '#value' => $langcode); diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index 8f26052..3b2d2ab 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -5,6 +5,8 @@ * Interface translation summary, editing and deletion user interfaces. */ +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + /** * String search screen. */ @@ -511,7 +513,7 @@ function locale_translate_delete_page($lid) { return drupal_get_form('locale_translate_delete_form', $source); } else { - return drupal_not_found(); + throw new NotFoundHttpException(); } } diff --git a/core/modules/openid/tests/openid_test.module b/core/modules/openid/tests/openid_test.module index 4481818..89f3ddf 100644 --- a/core/modules/openid/tests/openid_test.module +++ b/core/modules/openid/tests/openid_test.module @@ -22,6 +22,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Implements hook_menu(). @@ -98,7 +99,7 @@ function openid_test_yadis_xrds() { // that the XRI has been properly encoded. The "+" sign in the _xrd_r query // parameter is decoded to a space by PHP. if (arg(3) == 'xri' && (arg(4) != '@example*résumé;%25' || $_GET['_xrd_r'] != 'application/xrds xml')) { - drupal_not_found(); + throw new NotFoundHttpException(); } $output = ' diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 1ad7a85..f567dae 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -1034,9 +1034,8 @@ function search_box($form, &$form_state, $form_id) { */ function search_box_form_submit($form, &$form_state) { // The search form relies on control of the redirect destination for its - // functionality, so we override any static destination set in the request, - // for example by drupal_access_denied() or drupal_not_found() - // (see http://drupal.org/node/292565). + // functionality, so we override any static destination set in the request. + // See http://drupal.org/node/292565. if (isset($_GET['destination'])) { unset($_GET['destination']); } diff --git a/core/modules/statistics/statistics.admin.inc b/core/modules/statistics/statistics.admin.inc index 87ae6a5..3243b11 100644 --- a/core/modules/statistics/statistics.admin.inc +++ b/core/modules/statistics/statistics.admin.inc @@ -5,6 +5,8 @@ * Admin page callbacks for the Statistics module. */ +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + /** * Page callback: Displays the "recent hits" page. * @@ -225,7 +227,7 @@ function statistics_top_referrers() { * * @return array * A render array containing page access statistics. If information for the - * page was not found, drupal_not_found() is called. + * page was not found, NotFoundHttpException() is thrown. */ function statistics_access_log($aid) { $access = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = :aid', array(':aid' => $aid))->fetch(); @@ -264,7 +266,7 @@ function statistics_access_log($aid) { return $build; } else { - drupal_not_found(); + throw new NotFoundHttpException(); } } diff --git a/core/modules/statistics/statistics.pages.inc b/core/modules/statistics/statistics.pages.inc index 1b776d1..0a1d611 100644 --- a/core/modules/statistics/statistics.pages.inc +++ b/core/modules/statistics/statistics.pages.inc @@ -5,13 +5,15 @@ * User page callbacks for the Statistics module. */ +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + /** * Page callback: Displays statistics for a node. * * @return array * A render array containing node statistics. If information for the node was - * not found, this will deliver a page not found error via - * drupal_not_found(). + * not found, this will deliver a page not found error by throwing a + * NotFoundHttpException(). * * @see statistics_menu() */ @@ -58,7 +60,7 @@ function statistics_node_tracker() { return $build; } else { - drupal_not_found(); + throw new NotFoundHttpException(); } } @@ -67,8 +69,8 @@ function statistics_node_tracker() { * * @return array * A render array containing user statistics. If information for the user was - * not found, this will deliver a page not found error via - * drupal_not_found(). + * not found, this will deliver a page not found error by throwing a + * NotFoundHttpException(); * * @see statistics_menu() */ @@ -106,6 +108,6 @@ function statistics_user_tracker() { return $build; } else { - drupal_not_found(); + throw new NotFoundHttpException(); } } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 09ef3f5..519500e 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1,6 +1,7 @@