From 48bcc19ca276fab09d9a6c28fe2316a0288a528e Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Sat, 9 Oct 2004 06:52:35 +0000
Subject: - Patch #10613 by Gerhard: calling a non-existent username or user ID
 in the blog module URL now returns a 404 error instead of an empty blog page.

---
 modules/blog/blog.module | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

(limited to 'modules/blog/blog.module')

diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index ed50575c7..50db6cb7a 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -138,18 +138,23 @@ function blog_page($uid = 0) {
 function blog_page_user($uid) {
   $account = user_load(array((is_numeric($uid) ? 'uid' : 'name') => $uid, 'status' => 1));
 
-  $title = t("%name's blog", array('%name' => $account->name));
-  $output = '';
+  if ($account->uid) {
+    $title = t("%name's blog", array('%name' => $account->name));
+    $output = '';
 
-  $result = pager_query('SELECT DISTINCT(n.nid), n.sticky, n.created FROM {node} n '. node_access_join_sql() ." WHERE type = 'blog' AND n.uid = %d AND n.status = 1 AND ". node_access_where_sql() .' ORDER BY n.sticky DESC, n.created DESC', variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
-  while ($node = db_fetch_object($result)) {
-    $output .= node_view(node_load(array('nid' => $node->nid)), 1);
-  }
-  $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
-  $output .= theme('xml_icon', url("blog/feed/$account->uid"));
+    $result = pager_query('SELECT DISTINCT(n.nid), n.sticky, n.created FROM {node} n '. node_access_join_sql() ." WHERE type = 'blog' AND n.uid = %d AND n.status = 1 AND ". node_access_where_sql() .' ORDER BY n.sticky DESC, n.created DESC', variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
+    while ($node = db_fetch_object($result)) {
+      $output .= node_view(node_load(array('nid' => $node->nid)), 1);
+    }
+    $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
+    $output .= theme('xml_icon', url("blog/feed/$account->uid"));
 
-  drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url("blog/feed/$account->uid") .'" />');
-  print theme('page', $output, $title);
+    drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url("blog/feed/$account->uid") .'" />');
+    print theme('page', $output, $title);
+  }
+  else {
+    drupal_not_found();
+  }
 }
 
 /**
-- 
cgit v1.2.3