From 2510f322a183acd4040748ce9905d08de59fecb1 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Tue, 12 Oct 2004 20:01:25 +0000
Subject: [PATCH] - Modified patch #10613 by killes: generate a 'page not
 found'-page when a requested node does not exist.  I modified the patch to
 avoid duplicate 'not found'-checking in the second bulk.

---
 modules/node.module      | 40 +++++++++++++++++++++-------------------
 modules/node/node.module | 40 +++++++++++++++++++++-------------------
 2 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/modules/node.module b/modules/node.module
index b6e76329a988..996e7631e436 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -665,25 +665,26 @@ function node_menu($may_cache) {
   else {
     if (arg(0) == 'node' && is_numeric(arg(1))) {
       $node = node_load(array('nid' => arg(1)));
-
-      $items[] = array('path' => 'node/'. arg(1), 'title' => t('view'),
-        'callback' => 'node_page',
-        'access' => node_access('view', $node),
-        'type' => MENU_CALLBACK);
-      $items[] = array('path' => 'node/'. arg(1) .'/view', 'title' => t('view'),
-          'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
-      $items[] = array('path' => 'node/'. arg(1) .'/edit', 'title' => t('edit'),
-        'callback' => 'node_page',
-        'access' => node_access('update', $node),
-        'weight' => 1,
-        'type' => MENU_LOCAL_TASK);
-
-      if ($node->revisions) {
-        $items[] = array('path' => 'node/'. arg(1) .'/revisions', 'title' => t('revisions'),
+      if ($node->nid) {
+        $items[] = array('path' => 'node/'. arg(1), 'title' => t('view'),
           'callback' => 'node_page',
-          'access' => user_access('administer nodes'),
-          'weight' => 2,
+          'access' => node_access('view', $node),
+          'type' => MENU_CALLBACK);
+        $items[] = array('path' => 'node/'. arg(1) .'/view', 'title' => t('view'),
+            'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
+        $items[] = array('path' => 'node/'. arg(1) .'/edit', 'title' => t('edit'),
+          'callback' => 'node_page',
+          'access' => node_access('update', $node),
+          'weight' => 1,
           'type' => MENU_LOCAL_TASK);
+
+        if ($node->revisions) {
+          $items[] = array('path' => 'node/'. arg(1) .'/revisions', 'title' => t('revisions'),
+            'callback' => 'node_page',
+            'access' => user_access('administer nodes'),
+            'weight' => 2,
+            'type' => MENU_LOCAL_TASK);
+        }
       }
     }
   }
@@ -1474,8 +1475,9 @@ function node_page() {
       break;
     case 'view':
       if (is_numeric(arg(1))) {
-        if ($node = node_load(array('nid' => arg(1)), $_GET['revision'])) {
-          print theme('page', node_show($node, arg(3)), $node->title);
+        $node = node_load(array('nid' => arg(1)), $_GET['revision']);
+        if ($node->nid) {
+          print theme('page', node_show($node, arg(2)), $node->title);
         }
         else {
           drupal_not_found();
diff --git a/modules/node/node.module b/modules/node/node.module
index b6e76329a988..996e7631e436 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -665,25 +665,26 @@ function node_menu($may_cache) {
   else {
     if (arg(0) == 'node' && is_numeric(arg(1))) {
       $node = node_load(array('nid' => arg(1)));
-
-      $items[] = array('path' => 'node/'. arg(1), 'title' => t('view'),
-        'callback' => 'node_page',
-        'access' => node_access('view', $node),
-        'type' => MENU_CALLBACK);
-      $items[] = array('path' => 'node/'. arg(1) .'/view', 'title' => t('view'),
-          'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
-      $items[] = array('path' => 'node/'. arg(1) .'/edit', 'title' => t('edit'),
-        'callback' => 'node_page',
-        'access' => node_access('update', $node),
-        'weight' => 1,
-        'type' => MENU_LOCAL_TASK);
-
-      if ($node->revisions) {
-        $items[] = array('path' => 'node/'. arg(1) .'/revisions', 'title' => t('revisions'),
+      if ($node->nid) {
+        $items[] = array('path' => 'node/'. arg(1), 'title' => t('view'),
           'callback' => 'node_page',
-          'access' => user_access('administer nodes'),
-          'weight' => 2,
+          'access' => node_access('view', $node),
+          'type' => MENU_CALLBACK);
+        $items[] = array('path' => 'node/'. arg(1) .'/view', 'title' => t('view'),
+            'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
+        $items[] = array('path' => 'node/'. arg(1) .'/edit', 'title' => t('edit'),
+          'callback' => 'node_page',
+          'access' => node_access('update', $node),
+          'weight' => 1,
           'type' => MENU_LOCAL_TASK);
+
+        if ($node->revisions) {
+          $items[] = array('path' => 'node/'. arg(1) .'/revisions', 'title' => t('revisions'),
+            'callback' => 'node_page',
+            'access' => user_access('administer nodes'),
+            'weight' => 2,
+            'type' => MENU_LOCAL_TASK);
+        }
       }
     }
   }
@@ -1474,8 +1475,9 @@ function node_page() {
       break;
     case 'view':
       if (is_numeric(arg(1))) {
-        if ($node = node_load(array('nid' => arg(1)), $_GET['revision'])) {
-          print theme('page', node_show($node, arg(3)), $node->title);
+        $node = node_load(array('nid' => arg(1)), $_GET['revision']);
+        if ($node->nid) {
+          print theme('page', node_show($node, arg(2)), $node->title);
         }
         else {
           drupal_not_found();
-- 
GitLab