When a user logs in using a the user login block on, say, http://example.com/node/1, the form submits to http://example.com/node/1?destination=node/1. If the login succeeds, this user is redirected to http://example.com/node/1, i.e. the same page but now the user is logged in.
The redirect happens when the login block is rendered, i.e. via drupal_render_page() in index.php, through drupal_alter() → block_page_alter() → block_list() → _block_render_blocks() → user_block_view() → drupal_get_form() → drupal_process_form() → drupal_redirect_form().
If the page e.g. does some expensive database lookups, it is a waste of resources to generate it twice. This patch makes the form submit to a small menu callback that redirects to the referring page.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | user-login-5.patch | 3 KB | c960657 |
| #10 | user-login-4.patch | 3.02 KB | c960657 |
| #8 | user-login-3.patch | 3.01 KB | c960657 |
| #4 | user-login-2.patch | 2.96 KB | c960657 |
| user-login-1.patch | 2.8 KB | c960657 |
Comments
Comment #1
c960657 commented+Performance
Comment #2
moshe weitzman commentedComment #4
c960657 commentedReroll.
Comment #6
c960657 commentedTest bot glitch?
Comment #8
c960657 commentedReroll.
Comment #10
c960657 commentedReroll.
Comment #11
z1rra commentedI actually somehow got rid of this problem by converting all my template files in my theme to ANSI, instead of UTF-8. I have no idea how that works but there it is. Also, it somehow made my redirect to URL from login block not work.
Comment #12
c960657 commented#10: user-login-4.patch queued for re-testing.
Comment #13
catchPatch looks good, it'd also help with #2946: Login fails and no warning is issued if cookies are not enabled by making the redirect option there cheaper.
Comment #14
dries commentedSeems like the global $user could be removed?
Comment #15
c960657 commentedYou're right. Fixed.
Comment #16
marcingy commented#15: user-login-5.patch queued for re-testing.
Comment #17
dries commentedReading up on this patch again ...
1. I don't think this custom callback is that much cheaper.
2. I don't really understand this code comment, and how it is relevant to the underlying code. I'm sure I can figure it out, but it would be better if the comment made sense without additional research.
Comment #18
dries commentedComment #19
c960657 commentedThe patch has a problem when login fails: The username field that is reported as the problematic field using form_set_error() is not highlighted due to the redirect.
Comment #20
owen barton commentedComment #21
klonos...just saying that the issue title makes it look more like a bug rather than a task.
Comment #26
andypostLooks this issue makes no sense for d8
Comment #27
dpiDoesnt seem to be an issue in D7 or 8