bakery.module:935

      $login = bakery_user_external_login($account);
        if ($login) {
          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'] : '';
            unset($_GET['q']);
          }
          drupal_goto($destination, array('query' => $_GET));
        }

If any code calls current_path() before the Drupal shuts down, there will be an undefined index for $_GET['q'].

Comments

glennpratt’s picture

Status: Active » Needs review
StatusFileSize
new960 bytes

Followed a pattern seen elsewhere in Bakery.

dave reid’s picture

Status: Needs review » Needs work

We have a function for this. :)

drupal_goto($destination, array('query' => drupal_get_query_parameters()));
coltrane’s picture

Status: Needs work » Fixed

I didn't test, but it looks good. Thanks!

http://drupalcode.org/project/bakery.git/commit/0f56d3b

dave reid’s picture

I'm a little confused on what the intent of this code is. drupal_goto() automatically supports redirecting to $_GET['destination'] if it is set, so you don't need to manually pass and check it. Is the intent just to 'reload' the page for anonymous users if they get logged in?

dave reid’s picture

Ack, drupal_get_query_parameters cannot be used since it lies in includes/common.inc which is not loaded when hook_boot() runs.

dave reid’s picture

Hah, nevermind. I missed the drupal_bootstrap() call.

coltrane’s picture

Status: Fixed » Needs work

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); happens earlier in _bakery_taste_chocolatechip_cookie() if the cookie is valid, so drupal_get_query_parameters() should be available.

"Is the intent just to 'reload' the page for anonymous users if they get logged in?"

Yes.

dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new2.05 KB

Ok then this is the much simpler version of what you want for that code.

dave reid’s picture

+++ b/bakery.moduleundefined
@@ -72,7 +72,7 @@ function bakery_menu() {
@@ -433,7 +433,6 @@ function _bakery_login_submit($form, &$form_state) {

@@ -433,7 +433,6 @@ function _bakery_login_submit($form, &$form_state) {
   }
   // Create cookie and redirect to master.
   bakery_bake_oatmeal_cookie($data['name'], $data);
-  unset($_REQUEST['destination']);
   unset($_GET['destination']);
   drupal_goto(variable_get('bakery_master', 'http://drupal.org/') . 'bakery/login');
 }

This line is removed because in D6, core used $_REQUEST['destination']. In D7, core and any modules should only be using $_GET['destination']. This is likely a porting error and since I was messing with destination stuff I fixed this too.

tl;dr drupal_goto() for D7 doesn't give a crap about $_REQUEST at all. It only cares about $_GET.

coltrane’s picture

Won't this still run into the OP issue? That is that if anything calls current_path() before shutdown there will be an undefined index?

@glennpratt if you get a change to test this please report back here

dave reid’s picture

No because we're no longer unsetting $_GET['q'].

coltrane’s picture

Status: Needs review » Fixed
glennpratt’s picture

Thank you!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Fix typo