On the - admittedly strangely-built - site I'm currently working on, the Agreement module's use of $_SESSION to store the last-requested URL is resulting in users being sent back to paths such as sites/all/themes/foo/image.gif.

This is probably a result of the theme having one or two missing images which are called later than the page itself.

The simplest solution here would probably be to use $_GET[destination] in preference to $_SESSION; the code changes below prioritise $_GET over $_SESSION, but will fall back to the original module behaviour if something isn't working properly.

Change:

        drupal_goto(check_plain(variable_get('agreement_page_url',
        AGREEMENT_PAGE_URL)));
        exit();

... to:

        drupal_goto(check_plain(variable_get('agreement_page_url', AGREEMENT_PAGE_URL)), drupal_get_destination());
        exit();

and:

  elseif ($agreement_success_destination == '') {
    if ($_SESSION['agreement_destination'] == '') {
      $redirect = '<front>';
    }
    else {
      $redirect = $_SESSION['agreement_destination'];
    }
  }

... to:

  elseif ($agreement_success_destination == '') {
    if (isset($_GET['destination'])) {
      $redirect = $_GET['destination'];
    }
    elseif ($_SESSION['agreement_destination'] == '') {
      $redirect = '<front>';
    }
    else {
      $redirect = $_SESSION['agreement_destination'];
    }
  }

Again, apologies for the lack of a nice, sensible diff file :-$

Comments

pagaille’s picture

Apologies for not responding sooner - I missed this one, somehow. I will test asap. Thanks for the contribution!

pagaille’s picture

Status: Needs review » Needs work

This causes tests to fail and also causes the value set in "Agreement Success Destination" to be ignored.

mradcliffe’s picture

Version: 6.x-2.0-rc1 » 8.x-2.x-dev
Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Needs tests

Issue cleanup. This might still be something to consider in Drupal 8 and beyond, but need to investigate.

Adding needs tests and bumping the version number up to 8.x-2.x.