Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BC Break?] "Failed to start the session" error #12562

Closed
kbond opened this issue Nov 24, 2014 · 12 comments
Closed

[BC Break?] "Failed to start the session" error #12562

kbond opened this issue Nov 24, 2014 · 12 comments

Comments

@kbond
Copy link
Member

kbond commented Nov 24, 2014

After upgrading to 2.5.7 I started seeing this error very frequently. It looks like it has to do with #12341 and am only seeing it with PHP 5.3 (5.3.15 specifically). I don't appear to have the issue on PHP 5.5. When I revert to 2.5.6 everything worked as expected.

I am using the PdoSessionHandler.

Here is an excerpt from my logs:

[2014-11-23 11:01:07] security.DEBUG: Remember-me cookie detected. [] []
[2014-11-23 11:01:07] security.INFO: Remember-me cookie accepted. [] []
[2014-11-23 11:01:07] security.DEBUG: SecurityContext populated with remember-me token. [] []
[2014-11-23 11:01:07] security.DEBUG: Write SecurityContext in the session [] []
[2014-11-23 11:01:07] request.CRITICAL: Uncaught PHP Exception RuntimeException: "Failed to start the session: already started by PHP ($_SESSION is set)." at /.../vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php line 139 {"exception":"[object] (RuntimeException: Failed to start the session: already started by PHP ($_SESSION is set). at /.../vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php:139)"} []
[2014-11-23 11:01:07] security.DEBUG: Write SecurityContext in the session [] []

(Ref: #12325)

@kbond kbond changed the title "Failed to start the session" error [BC Break?] "Failed to start the session" error Nov 25, 2014
@mcrio
Copy link

mcrio commented Nov 26, 2014

After upgrading to 2.5.7 I am getting the same issue when using StreamedResponse, PHP 5.3.10.
2.5.6 works fine.

@kbond
Copy link
Member Author

kbond commented Nov 26, 2014

I am not using StreamedResponse - looks like @nikolajosipovic's issue has been reported here: #12423. I am unsure if this issue is related.

@kbond
Copy link
Member Author

kbond commented Nov 27, 2014

Few more notes about this issue:

I am using Symfony's HttpCache, I have a cached full-page layout with an esi fragment that is not cached and accessing the session. I think the exception is being raised during rendering the fragment.

@weaverryan
Copy link
Member

@kbond not sure if this is feasible to test, but does manually reverting only #12326 fix the issue? It's the only thing I see on the changelog that looks related - it would at least help confirm things (though the specifics are over my head).

@kbond
Copy link
Member Author

kbond commented Nov 27, 2014

Good idea :). Reverting #12326 didn't fix the issue but reverting #12341 did (commit b7bfef0)

@Tobion
Copy link
Member

Tobion commented Nov 28, 2014

I'll provide a fix on the weekend.

@AITG
Copy link

AITG commented Dec 2, 2014

Just to add another 'me too' here. Just updated from 2.3.5 to 2.3.22 and I get the "RuntimeException: Failed to start the session: already started by PHP ($_SESSION is set)." error.

The exception is raised from here:

cache/dev/classes.php

NativeSessionStorage->start()
...
if (version_compare(phpversion(),'5.4.0','<') && isset($_SESSION) && session_id()) {
throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).');
}

That line has changed in 2.3.22,

if (PHP_VERSION_ID < 50400 && isset($_SESSION) && session_id()) {
throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).');
}
Downgrading to 2.3.21 fixes it.

God knows the reason for changing what appears to be a perfectly fine block of code though.

@crashbtz
Copy link

crashbtz commented Dec 5, 2014

we had the same problem with php 5.3.27 and that was caused by the "render_esi" command so we removed it temporarily

@Seldaek
Copy link
Member

Seldaek commented Dec 10, 2014

@Tobion I know how it is with weekend projects, but any news on this by any chance? Otherwise could we revert b7bfef0 @fabpot as this is a regression?

@kbond
Copy link
Member Author

kbond commented Dec 12, 2014

Is this related to #12833?

@Tobion
Copy link
Member

Tobion commented Dec 12, 2014

See #12961 for a fix

fabpot added a commit that referenced this issue Dec 12, 2014
This PR was merged into the 2.3 branch.

Discussion
----------

fix session restart on PHP 5.3

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets | #12562
| License       | MIT
| Doc PR        | -

this also removes some useless code

Commits
-------

b9d3c92 fix session restart on PHP 5.3
@fabpot fabpot closed this as completed Dec 12, 2014
@Seldaek
Copy link
Member

Seldaek commented Dec 13, 2014

Just confirming that the fix works for me thanks @Tobion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants