Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.310
diff -u -r1.310 common.inc
--- includes/common.inc	17 Jan 2004 23:19:02 -0000	1.310
+++ includes/common.inc	18 Jan 2004 20:21:32 -0000
@@ -224,7 +224,7 @@
  */
 function drupal_not_found() {
   header("HTTP/1.0 404 Not Found");
-  watchdog("httpd", "404 error: '". check_query($_GET["q"]) ."' not found");
+  watchdog("httpd", "404 error: '". check_query($_GET['q']) ."' not found");
 
   $path = drupal_get_normal_path(variable_get('site_404', ''));
 
@@ -1124,12 +1124,17 @@
 // spit out the correct charset http header
 header("Content-Type: text/html; charset=utf-8");
 
-// initialize the _GET["q"] prior to loading the modules and invoking their 'init' hook:
-if (!empty($_GET["q"])) {
-  $_GET["q"] = drupal_get_normal_path(trim($_GET["q"], "/"));
+// save the referrer:
+if (empty($_POST)) {
+  $_SESSION['referrer'] = referrer_uri();
+}
+
+// initialize the _GET['q'] prior to loading the modules and invoking their 'init' hook:
+if (!empty($_GET['q'])) {
+  $_GET['q'] = drupal_get_normal_path(trim($_GET['q'], "/"));
 }
 else {
-  $_GET["q"] = drupal_get_normal_path(variable_get("site_frontpage", "node"));
+  $_GET['q'] = drupal_get_normal_path(variable_get("site_frontpage", "node"));
 }
 
 // initialize installed modules:
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.8
diff -u -r1.8 bootstrap.inc
--- includes/bootstrap.inc	14 Jan 2004 22:30:08 -0000	1.8
+++ includes/bootstrap.inc	18 Jan 2004 20:21:32 -0000
@@ -178,7 +178,7 @@
   return $obj;
 }
 
-function referer_uri() {
+function referrer_uri() {
   if (isset($_SERVER["HTTP_REFERER"])) {
     return check_url($_SERVER["HTTP_REFERER"]);
   }
Index: modules/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user.module,v
retrieving revision 1.288
diff -u -r1.288 user.module
--- modules/user.module	13 Jan 2004 19:25:37 -0000	1.288
+++ modules/user.module	18 Jan 2004 20:21:38 -0000
@@ -334,18 +334,8 @@
 
           $output = "<div class=\"user-login-block\">\n";
 
-          /*
-          ** Save the referer.  We record where the user came from such
-          ** that we/ can redirect him after having completed the login
-          ** form.
-          */
-
-          if (empty($edit)) {
-            $edit["destination"] = url($_GET["q"]);
-          }
           // NOTE: special care needs to be taken because on pages with forms, such as node and comment submission pages, the $edit variable might already be set.
 
-          $output .= form_hidden("destination", $edit["destination"]);
           $output .= form_textfield(t("Username"), "name", $edit["name"], 15, 64);
           $output .= form_password(t("Password"), "pass", $pass, 15, 64);
 
@@ -622,7 +612,7 @@
       ** Redirect the user to the page he logged on from.
       */
 
-      drupal_goto($edit["destination"]);
+      drupal_goto($_SESSION['referrer']);
     }
     else {
       if (!$error) {
Index: modules/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics.module,v
retrieving revision 1.134
diff -u -r1.134 statistics.module
--- modules/statistics.module	11 Jan 2004 20:31:25 -0000	1.134
+++ modules/statistics.module	18 Jan 2004 20:21:41 -0000
@@ -20,7 +20,7 @@
 
   if ((variable_get("statistics_enable_access_log", 0)) && (module_invoke("throttle", "status") < 5)) {
     // statistical logs are enabled
-    $referrer = referer_uri();
+    $referrer = referrer_uri();
     $hostname = getenv("REMOTE_ADDR");
     // log this page access
     if ((arg(0) == "node") && (arg(1) == "view") && arg(2)) {
Index: modules/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node.module,v
retrieving revision 1.317
diff -u -r1.317 node.module
--- modules/node.module	17 Jan 2004 09:07:00 -0000	1.317
+++ modules/node.module	18 Jan 2004 20:21:44 -0000
@@ -1387,6 +1387,10 @@
     }
   }
 
+  if ($_SESSION['referrer']) {
+    drupal_goto($_SESSION['referrer']);
+  }
+
   $node = node_load(array("nid" => $node->nid));
   drupal_set_message($msg);
   drupal_set_title($node->title);
