diff --git a/core/includes/common.inc b/core/includes/common.inc index 29f1ef117ead4733647a43fe70c58e0dd9fe90f7..3706049d68f67eaf0d202d6836fbc33d4fdcd187 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -698,18 +698,6 @@ function drupal_site_offline() { drupal_deliver_page(MENU_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. * @@ -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 f6cab86758b80d0cdea5cba1a0e7d4b7f7b7081d..d6d84705890edf0e74fcee2a99d8456256fbb32a 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 aedde1654ae8ead0bb726ea452fe305a5f520a6e..c00fb6fcb2a50e8d85a1fa3aafd6c4a2a1717c0a 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 9eabe13ea06390ad8cde92f389c9dcde74fbbf25..4329492a565cd9d4bc707251beaf1cbf479a1638 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 58ea4a61550020ac2d5b479535c83e3fd2f41927..4fa8fee71d6dfbbbbf5180b93e5377e80a0978ba 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 2986d135d9ac0b995f15eeeaed4eec1425271c99..39b8a24456bd7939806f6319206e90d10569fed5 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 bf096a7b8ee438b9a171b3b513aaee4e0dd48abb..a1c29264a00105740a656406089b84fa291b466c 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 c124b9e32b529c8172cb7b2b7c0be0857567a80d..8fe85be4788f282074b529f0ec1a771cf3a0d4bd 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 8f260521bcfe77e7d0d2bcbcd48b7f012fd6bdc9..3b2d2abc9a35e595cd26136890426ec6b792a589 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 4481818c8b4a736f90b8c2e58d083f46d2464ed1..89f3ddf62a573f4120b9dde4f64f177bb0182e32 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 1ad7a850f892d041c10fedb3a53a4b6e5935bae3..f567dae2d9d00b8dbdb3f7cda8c52e7ec0fcedf3 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 87ae6a540d19fc5d13913ce6c12a8e695b6151a6..ea608a43c93d2a4124a9aca4960cf7419ff4b36f 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, a 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 1b776d1fdacbafb8440aa03b5763f477912d082a..586189aad1b4851832cb1b64bb636de42028229a 100644 --- a/core/modules/statistics/statistics.pages.inc +++ b/core/modules/statistics/statistics.pages.inc @@ -5,13 +5,14 @@ * 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 throw a NotFoundHttpException. * * @see statistics_menu() */ @@ -58,7 +59,7 @@ function statistics_node_tracker() { return $build; } else { - drupal_not_found(); + throw new NotFoundHttpException(); } } @@ -67,8 +68,7 @@ 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 throw a NotFoundHttpException. * * @see statistics_menu() */ @@ -106,6 +106,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 09ef3f55beba95cc93cb6dc34b332b75934e6d7f..519500ecfcdfefbd7c0386cc121dac4f7a1be70b 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1,6 +1,7 @@