server icon indicating copy to clipboard operation
server copied to clipboard

Don't call session_start() when PHP session is still or already open.

Open rotdrop opened this issue 3 years ago • 11 comments

Signed-off-by: Claus-Justus Heine [email protected]

See #31248

rotdrop avatar Feb 20 '22 23:02 rotdrop

https://github.com/nextcloud/server/pull/28695 was an older alternative, not sure which is best

PVince81 avatar Jun 10 '22 15:06 PVince81

#28695 was an older alternative, not sure which is best

No idea :confused:

come-nc avatar Jun 13 '22 07:06 come-nc

I've been trying to figure out why we actually need the session_start when clearing and generating a new session id, but couldn't find a good reasoning from the git history nor php documentation so I would consider even dropping that call. But hard to tell if that has any side effects.

So either the start_session is superfluous and can be omitted -- at least in current versions of php -- or there is missing something like a session_destroy() (but then regenerate_id() could be omitted?) or a session_write_close() which would write the (now empty) session file to disk.

@rotdrop Did you have any reasoning to go with the session_write_close instead of dropping the start_session?

juliusknorr avatar Jul 07 '22 13:07 juliusknorr

session_write_close should basically break @UseSession annotation?

nickvergessen avatar Jul 08 '22 08:07 nickvergessen

session_write_close should basically break @UseSession annotation?

No as the session_start would reopen it for writing.

juliusknorr avatar Jul 08 '22 09:07 juliusknorr

#28695 was an older alternative, not sure which is best

Both perform a similar goal, this one seems more clean.

solracsf avatar Aug 25 '22 10:08 solracsf

/rebase

come-nc avatar Sep 01 '22 08:09 come-nc

Is this still a thing after https://github.com/nextcloud/server/commit/9e1d4312555ddc1009450b1f6b7078ae35790593? Cc @juliushaertl

solracsf avatar Sep 20 '22 11:09 solracsf

Is this still a thing after 9e1d431? Cc @juliushaertl

Yes, that linked commit only reduced one common case where a session would be opened for writing. This might still occur later in the code path.

juliusknorr avatar Dec 28 '22 07:12 juliusknorr

/rebase

juliusknorr avatar Dec 28 '22 07:12 juliusknorr

@rotdrop Can you maybe rebase your PR so we trigger CI again and can get this merged?

juliusknorr avatar Dec 28 '22 07:12 juliusknorr