Commit 356aa34d authored by Dries's avatar Dries

- Patch #1587850 by pfrenssen, chrisdolby: replace drupal_not_found() with...

- Patch #1587850 by pfrenssen, chrisdolby: replace drupal_not_found() with throw NotFoundHttpException.
parent b9133016
......@@ -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
......
......@@ -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()
......
......@@ -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 {
......
......@@ -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();
}
/**
......
......@@ -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();
}
/**
......
......@@ -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();
}
......@@ -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. <a href="@add">Add one or more categories</a> to the form.', array('@add' => url('admin/structure/contact/add'))), 'error');
}
else {
drupal_not_found();
drupal_exit();
throw new NotFoundHttpException();
}
}
......
......@@ -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);
......
......@@ -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();
}
}
......
......@@ -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 = '<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)" xmlns:openid="http://openid.net/xmlns/1.0">
......
......@@ -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']);
}
......
......@@ -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();
}
}
......
......@@ -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();
}
}
<?php
use Drupal\Core\Database\Query\SelectInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* @file
......@@ -2333,7 +2334,7 @@ function user_view_page($account) {
}
// An administrator may try to view a non-existent account,
// so we give them a 404 (versus a 403 for non-admins).
drupal_not_found();
throw new NotFoundHttpException();
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment