? 574084_bakery_page_caching_39_0.patch
? 574084_bakery_page_caching_45.patch
? 948906-bakery-oatmeal-cookie-3.patch
Index: bakery.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bakery/bakery.module,v
retrieving revision 1.52.4.3
diff -u -p -r1.52.4.3 bakery.module
--- bakery.module	28 Oct 2010 00:24:15 -0000	1.52.4.3
+++ bakery.module	28 Oct 2010 00:27:20 -0000
@@ -167,9 +167,9 @@ function bakery_user($op, &$array, &$acc
 }
 
 /**
- * Implementation of hook_init().
+ * Implementation of hook_boot().
  */
-function bakery_init() {
+function bakery_boot() {
   _bakery_taste_chocolatechip_cookie();
 }
 
@@ -745,6 +745,8 @@ function _bakery_taste_chocolatechip_coo
     _bakery_bake_chocolatechip_cookie($cookie['name'], $cookie['mail'], $cookie['init']);
 
     if (!$user->uid) {
+      // Since this might happen in hook_boot we need to bootstrap first.
+      drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
       // User is anonymous. If they do not have an account we'll create one by
       // requesting their information from the master site. If they do have an
       // account we may need to correct some disparant information.
@@ -819,11 +821,20 @@ function _bakery_taste_chocolatechip_coo
 
       if ($account && $user->uid == 0) {
         bakery_user_external_login($account);
+        if (isset($_REQUEST['destination'])) {
+          $destination = $_REQUEST['destination'];
+        }
+        else {
+          // Use $_GET here to retrieve the original path in source form.
+          $destination = isset($_GET['q']) ? $_GET['q'] : '';
+          $query = drupal_query_string_encode($_GET, array('q'));
+        }
+        drupal_goto($destination, $query);
       }
     }
     if ($destroy_cookie !== TRUE) {
       return TRUE;
-    } 
+    }
   }
 
   // Eat the bad cookie. Burp.
