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

larowlan’s picture

Issue summary: View changes

Updated issue summary.

andypost’s picture

Now I get the issue in all browsers

tim.plunkett’s picture

It works on minimal profile, but not standard.

tim.plunkett’s picture

Issue summary: View changes

Updated issue summary.

larowlan’s picture

This 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

elvis2’s picture

@larowlan, can you provide a patch to test?

sun’s picture

andypost’s picture

some days ago (when install in other then English language work) no login was needed after install

sun’s picture

note that this doesn't occur in minimal either.

I'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.

sun’s picture

The 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:

  1. A parallel HTTP request hits the Drupal site within the installer before the site is fully set up. → e.g., the built-in PoormansCron facility in core (a cron run triggered through a JS callback)
  2. Something else quite possibly related to either cron or sessions.
sun’s picture

#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.

kartagis’s picture

I git pull'd yesterday and installed, the error seems to have gone away.

tim.plunkett’s picture

I'm still logged out after installing.

berdir’s picture

Noticed today that I was logged in when doing a non-english installation (german), but not when installing with english.

kartagis’s picture

Yeah, I can confirm #12. In my case, it was Turkish.

znerol’s picture

It seems that this is related to the batch process running as the last step (when translation is enabled) and lacking (when installing in english).

znerol’s picture

Funny 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.

tim.plunkett’s picture

I also am logged in when I install with JS off. Nice find @znerol!

sun’s picture

Yeah, that confirms my suspicion in #8.

Either some Ajax callback or PoormansCron, or some other funky/fragile JS callback (#post_render_cache, active-links, .....)

valthebald’s picture

Assigned: Unassigned » valthebald

I have narrowed it to commenting the call to

        var path = 'system/timezone/' + abbreviation + '/' + offsetNow + '/' + isDaylightSavingTime;

in timezone.js

Now looking what could be the issue

valthebald’s picture

Issue summary: View changes
Status: Active » Needs review
Issue tags: +Needs manual testing
StatusFileSize
new1.11 KB
valthebald’s picture

Issue summary: View changes
andypost’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs manual testing

Awesome!
Tested in FF and chrome, also simplytest.me

sun’s picture

Awesome 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? :)

valthebald’s picture

@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:

  1. install.php: All the way of install.php user session exists (uid = 0, but there is batch info)
  2. install.php:final step of install.php loads. User session still present
  3. index.php:timezone AJAX call destroys user session
  4. install.php:install.php is submitted
  5. install.php:user 1 is updated, session is regenerated, but not saved
  6. install.php:since session doesn't exist (it was destroyed by #3), it is reset by cache clear

Also, chances are that the issue is related to session subsystem still using global $user. Hopefully this will go away from core

valthebald’s picture

StatusFileSize
new1.2 KB
new461 bytes

Added comment

catch’s picture

Status: Reviewed & tested by the community » Fixed

Nice find. Committed/pushed to 8.x, thanks!

  • Commit 766586b on 8.x by catch:
    Issue #2108623 by valthebald: Installing via the UI no longer logs in...

Status: Fixed » Closed (fixed)

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