Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.892
diff -u -p -r1.892 common.inc
--- includes/common.inc	4 May 2009 10:38:47 -0000	1.892
+++ includes/common.inc	4 May 2009 22:07:26 -0000
@@ -358,11 +358,6 @@ function drupal_not_found() {
 
   watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
 
-  // Keep old path for reference.
-  if (!isset($_REQUEST['destination'])) {
-    $_REQUEST['destination'] = $_GET['q'];
-  }
-
   $path = drupal_get_normal_path(variable_get('site_404', ''));
   if ($path && $path != $_GET['q']) {
     // Custom 404 handler. Set the active item in case there are tabs to
@@ -389,13 +384,9 @@ function drupal_not_found() {
  */
 function drupal_access_denied() {
   drupal_set_header('403 Forbidden');
+  
   watchdog('access denied', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
 
-  // Keep old path for reference.
-  if (!isset($_REQUEST['destination'])) {
-    $_REQUEST['destination'] = $_GET['q'];
-  }
-
   $path = drupal_get_normal_path(variable_get('site_403', ''));
   if ($path && $path != $_GET['q']) {
     // Custom 403 handler. Set the active item in case there are tabs to
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.332
diff -u -p -r1.332 form.inc
--- includes/form.inc	1 May 2009 14:51:41 -0000	1.332
+++ includes/form.inc	4 May 2009 22:07:26 -0000
@@ -722,12 +722,6 @@ function drupal_redirect_form($form, $re
   }
   if (!isset($goto) || ($goto !== FALSE)) {
     if (isset($goto)) {
-      // Remove any fake destination set by drupal_not_found() or
-      // drupal_access_denied() so that we can properly redirect from those
-      // pages.
-      if (isset($_REQUEST['destination']) && $_REQUEST['destination'] == $_GET['q']) {
-        unset($_REQUEST['destination']);
-      }
       if (is_array($goto)) {
         call_user_func_array('drupal_goto', $goto);
       }
Index: modules/user/user.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.test,v
retrieving revision 1.34
diff -u -p -r1.34 user.test
--- modules/user/user.test	25 Apr 2009 17:52:43 -0000	1.34
+++ modules/user/user.test	4 May 2009 22:07:27 -0000
@@ -923,6 +923,30 @@ class UserBlocksUnitTests extends Drupal
   }
 
   /**
+   * Test the user login block.
+   */
+  function testUserLoginBlock() {
+    // Create a user with some permission that anonymous users lack.
+    $user = $this->drupalCreateUser(array('administer permissions'));
+
+    // Log in using the block.
+    $edit = array();
+    $edit['name'] = $user->name;
+    $edit['pass'] = $user->pass_raw;
+    $this->drupalPost('admin/user/permissions', $edit, t('Log in'));
+    $this->assertText(t('Log out'), t('Logged in.'));
+
+    // Check that we are still on the same page.
+    $this->assertPattern('!<title.*?' . t('Permissions') . '.*?</title>!', t('Still on the same page after login'));
+
+    // Now, log out and repeat with a non-403 page.
+    $this->clickLink(t('Log out'));
+    $this->drupalPost('filter/tips', $edit, t('Log in'));
+    $this->assertText(t('Log out'), t('Logged in.'));
+    $this->assertPattern('!<title.*?' . t('Compose tips') . '.*?</title>!', t('Still on the same page after login'));
+  }
+
+  /**
    * Test the Who's Online block.
    */
   function testWhosOnlineBlock() {
