Page MenuHomePhabricator

'Warning: session_id(): Cannot change session id when session is active' intermittently on php7.3
Closed, ResolvedPublic

Description

Warning: session_id(): Cannot change session id when session is active in /mediawiki/core/includes/Setup.php on line 879

Happens every time I come back to the wiki after a significant delay. No issues when (re)loading pages after that, until the session expires again.

Details

Related Gerrit Patches:

Event Timeline

Isarra created this task.Jan 10 2019, 10:21 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 10 2019, 10:21 PM

I assume this is php 7.3-related; it's not happening on my other wikis, but I'm also not actually sure when it got updated in my dev environment, nor how to try downgrading it to check, either, so I could be wrong.

I can reproduce this with Firefox 64 by logging in with "Remember me" checked and using the Storage Inspector (Shift+F9) to delete the mywiki_session cookie.

When Setup.php fetches the session in this situation, SessionManager uses the Token cookie to create a new session for the logged-in user and immediately saves it, which has the side effect of starting the PHP session. So when Setup.php also tries to start the PHP session with the same session ID, it was already started.

In older versions of PHP this just caused a warning from session_start(), which we've been silencing. Now, though, PHP 7.3 complains about (and ignores) the session_id() call, so we need to do something different.

Change 483949 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@master] Avoid session double-start in Setup.php

https://gerrit.wikimedia.org/r/483949

Had an old 1.28 wiki on mothballs and tried to upgrade it to 1.31 a couple weeks ago. Saw posts that PHP 7.3 compatibility issues were to be blame and were to be fixed when 1.32 came out. The conversion seemed to go through just fine, but this issue remains.

However, when I just create a from brand new bare Wiki, everything is fine. Same user name, log in, no issues. If I change $wgDBname in the fresh install to the "mothballed" Wiki's DB, it instantly breaks with the "Cannot change session ID" error, even if already logged in.

I'm no dev -- just came here looking for a solution -- but it seems like there's a DB conversion issue perhaps?

Change 484683 had a related patch set uploaded (by Reedy; owner: Anomie):
[mediawiki/core@REL1_32] Avoid session double-start in Setup.php

https://gerrit.wikimedia.org/r/484683

Change 484684 had a related patch set uploaded (by Reedy; owner: Anomie):
[mediawiki/core@REL1_31] Avoid session double-start in Setup.php

https://gerrit.wikimedia.org/r/484684

Change 484687 had a related patch set uploaded (by Reedy; owner: Anomie):
[mediawiki/core@REL1_30] Avoid session double-start in Setup.php

https://gerrit.wikimedia.org/r/484687

Reedy added a comment.Jan 16 2019, 3:17 PM

Had an old 1.28 wiki on mothballs and tried to upgrade it to 1.31 a couple weeks ago. Saw posts that PHP 7.3 compatibility issues were to be blame and were to be fixed when 1.32 came out. The conversion seemed to go through just fine, but this issue remains.

Many were fixed, but not all of them. There's been some other stuff surface too

However, when I just create a from brand new bare Wiki, everything is fine. Same user name, log in, no issues. If I change $wgDBname in the fresh install to the "mothballed" Wiki's DB, it instantly breaks with the "Cannot change session ID" error, even if already logged in.
I'm no dev -- just came here looking for a solution -- but it seems like there's a DB conversion issue perhaps?

It's not a DB conversion issue, there are some fairly big session handling changes in PHP 7.3

Depending on your comfortable-ness with things, either downgrade to PHP 7.2, or wait for 1.32.1 (see T213595: Release 1.32.1 as a maintenance release) which should be coming out "soon" to clear up various issues

Change 483949 merged by jenkins-bot:
[mediawiki/core@master] Avoid session double-start in Setup.php

https://gerrit.wikimedia.org/r/483949

Change 484683 merged by jenkins-bot:
[mediawiki/core@REL1_32] Avoid session double-start in Setup.php

https://gerrit.wikimedia.org/r/484683

Change 484684 merged by jenkins-bot:
[mediawiki/core@REL1_31] Avoid session double-start in Setup.php

https://gerrit.wikimedia.org/r/484684

Change 484687 merged by jenkins-bot:
[mediawiki/core@REL1_30] Avoid session double-start in Setup.php

https://gerrit.wikimedia.org/r/484687

Reedy closed this task as Resolved.Jan 16 2019, 3:39 PM
Reedy claimed this task.
Reedy reassigned this task from Reedy to Anomie.
Reedy removed a project: Patch-For-Review.

Depending on your comfortable-ness with things, either downgrade to PHP 7.2, or wait for 1.32.1 (see T213595: Release 1.32.1 as a maintenance release) which should be coming out "soon" to clear up various issues

I think I might wait for 1.32.1 then. Tried regressing XAMPP back to using PHP 7.2 and other things broke. We'll see how long Soon™ takes.

issu not solved
Warning: session_id(): Cannot change session id when session is active

I made a temporary fix in my installation on includes/setup.php

change :

session_id( $session->getId() );

to :

@session_id( $session->getId() );

issu not solved

Which version of MediaWiki are you using?

Note there hasn't been a 1.32.1 or 1.31.2 release yet, so you'd have to be running the unreleased REL1_32 or REL1_31 branch head (or have manually applied the patch linked from this task) to actually know whether it's solved or not.

yakatz added a subscriber: yakatz.May 8 2019, 8:34 PM