Updated: Comment #19
Problem/Motivation
Installing via the UI no longer logs in user 1 reliably.
Eg myself (@larowlan using simplytest.me and chrome) and @ParisLiakos (5.5) reported it didn't work
@andypost (5.3.14) reported it did in chrome but not in firefox.
@tim.plunkett tried chrome on 5.3.14 and 5.4.4, and neither worked.
This means we can't do the front page tour.
And that the initial experience is that of an anonymous user.
Diagnosis: user is logged in in install_configure_form_submit(). Later, in install_finished(), drupal_flush_all_caches() re-initializes user session:
$cookies = \Drupal::request()->cookies;
if (($cookies->has(session_name()) && ($session_name = $cookies->get(session_name()))) || ($is_https && Settings::get('mixed_mode_sessions', FALSE) && ($cookies->has(substr(session_name(), 1))) && ($session_name = $cookies->get(substr(session_name(), 1))))) {
// If a session cookie exists, initialize the session. Otherwise the
// session is only started on demand in drupal_session_commit(), making
// anonymous users not use a session cookie unless something is stored in
// $_SESSION. This allows HTTP proxies to cache anonymous pageviews.
drupal_session_start();
if ($user->isAuthenticated() || !empty($_SESSION)) {
drupal_page_is_cacheable(FALSE);
}
}
else {
// Set a session identifier for this request. This is necessary because
// we lazily start sessions at the end of this request, and some
// processes (like drupal_get_token()) needs to know the future
// session ID in advance.
$GLOBALS['lazy_session'] = TRUE;
$user = new AnonymousUserSession();
...
Proposed resolution
Move user log in into install_finished()
Remaining tasks
Tests - is this testable? I see only manual testing option
Review
User interface changes
None
API changes
None
None
Comments
Comment #0.0
larowlanUpdated issue summary.
Comment #1
andypostNow I get the issue in all browsers
Comment #2
tim.plunkettIt works on minimal profile, but not standard.
Comment #2.0
tim.plunkettUpdated issue summary.
Comment #3
larowlanThis is definitely the cron run, and something to do with cookies, the cookie sent by the browser is removed by Drupal, a new session is created - so the old one is invalid.
Removing the call to cron in install finished fixes it, note that this doesn't occur in minimal either.
Lee
Comment #4
elvis2 commented@larowlan, can you provide a patch to test?
Comment #5
sunComment #6
andypostsome days ago (when install in other then English language work) no login was needed after install
Comment #7
sunI'm not able to confirm this. I re-installed a couple of times with Minimal profile this week and was never logged in after installation.
Scanning the changelog of install.core.inc, there are two issues that touched the final uid 1 user account saving and login procedure:
#2002650: [meta, no patch] improve maintainability by removing unused local variables
#1987896: [Change record update] Convert user_page() to a new style controller
However, I'm not able to see how these could have broken the final login/authentication.
Comment #8
sunThe interactive installer is now covered by proper automated tests, due to #2171683: Remove all Simpletest overrides and rely on native multi-site functionality instead
The automated tests are passing. Therefore, this issue can have two potential causes:
Comment #9
sun#2205295: Objectify session handler reliably reproduces this bug in automated tests (out of a sudden), so it is likely going to be fixed as part of that issue.
Comment #10
kartagisI git pull'd yesterday and installed, the error seems to have gone away.
Comment #11
tim.plunkettI'm still logged out after installing.
Comment #12
berdirNoticed today that I was logged in when doing a non-english installation (german), but not when installing with english.
Comment #13
kartagisYeah, I can confirm #12. In my case, it was Turkish.
Comment #14
znerol commentedIt seems that this is related to the batch process running as the last step (when translation is enabled) and lacking (when installing in english).
Comment #15
znerol commentedFunny detail: I end up as logged in user when installing with JavaScript disabled. That explains why it was not detected by the tests. I suspect that the '/system/timezone' Ajax callback is causing the trouble.
Comment #16
tim.plunkettI also am logged in when I install with JS off. Nice find @znerol!
Comment #17
sunYeah, that confirms my suspicion in #8.
Either some Ajax callback or PoormansCron, or some other funky/fragile JS callback (#post_render_cache, active-links, .....)
Comment #18
valthebaldI have narrowed it to commenting the call to
in timezone.js
Now looking what could be the issue
Comment #19
valthebaldComment #20
valthebaldComment #21
andypostAwesome!
Tested in FF and chrome, also simplytest.me
Comment #22
sunAwesome that you fixed it!
However, what is the actual fix (or problem)...? How does moving those two lines change the situation?
Is it possible to cover that in a code comment, to prevent those lines to get mistakenly moved to somewhere else by someone else in the future? :)
Comment #23
valthebald@sun: I was not able to track it down to the end, yet I'm sure that it happened due to different handling of user session by install.php (all the way until the final step) and index.php (request to TimeZone controller). It went like this:
Also, chances are that the issue is related to session subsystem still using global $user. Hopefully this will go away from core
Comment #24
valthebaldAdded comment
Comment #25
catchNice find. Committed/pushed to 8.x, thanks!