You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: \OC::$server->getSession()->set('key', 'value') not saved #34935
You are probably using lib/private/Session/Memory.php instead of lib/private/Session/Internal.php, unfortunately I have no idea how the Internal session is used and it seems only the Memory session are actually used
@juliushaertl do you have an idea why we are using the in memory session handling?
Maybe you could add some logging to that to see if that is the case. Otherwise maybe you can provide the link to where the setSession in your apps code doesn't take effect, then I could have a quick look.
The code is executed after the App Controller is called.
Go to: /nextcloud/index.php/apps/snappymail/
appinfo/routes.php has `page#index`
Nextcloud calls `OCA\SnappyMail\Controller\PageController::index()`
That calls SnappyMailHelper::startApp()
startApp() tries to do a check due complications with the Impersonate app
You may need to add the @UseSession annotation to your controller method then, as otherwise ISession::set is called after the session has been closed for writing already.
Ok, so for Nextcloud 25 there would be a way to reopen the session with #32162
Now I don't have much insight into the impersonate app but with the described behavior I would imagine this also has all kind of issues with external storages where the login data is stored in the session and probably other session-related cases.
Maybe @blizzz has any further insight as the main contributor to the impersonate app?
This approach has more IOPS when setting multiple.
So the ->close() could also be done by process/app itself.
This way the session:
has shortest lock ever
session_abort closes session without write
set() reopens session with lock
lock stays active until close()
This would also solve my problem if the Impersonate (or other app) provides similar issues.
Then i can write to Session any time i want and (auto)->close() to unlock asap
Oh never mind my response. I looked at the first code but the real solution was later on in the thread.
You all did what i mention using the $this->reopen() 👍
Activity
szaimen commentedon Nov 3, 2022
Which NC version?
the-djmaze commentedon Nov 3, 2022
24.0.6
CarlSchwan commentedon Nov 3, 2022
You are probably using
lib/private/Session/Memory.phpinstead oflib/private/Session/Internal.php, unfortunately I have no idea how the Internal session is used and it seems only the Memory session are actually used@juliushaertl do you have an idea why we are using the in memory session handling?
juliusknorr commentedon Nov 3, 2022
The only scenario I would have in mind is if your call to getSession is actually taking place before the initSession call of Nextcloud.
server/lib/base.php
Line 418 in 11bedf1
Maybe you could add some logging to that to see if that is the case. Otherwise maybe you can provide the link to where the setSession in your apps code doesn't take effect, then I could have a quick look.
the-djmaze commentedon Nov 3, 2022
The code is executed after the App Controller is called.
Here is the code block (with ocSession disabled):
https://github.com/the-djmaze/snappymail/blob/39a827aa2e4fb11ea7cbea488b768ac2bee1012b/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php#L104-L127
juliusknorr commentedon Nov 3, 2022
You may need to add the
@UseSessionannotation to your controller method then, as otherwiseISession::setis called after the session has been closed for writing already.https://docs.nextcloud.com/server/latest/developer_manual/basics/controllers.html#reading-and-writing-session-variables
the-djmaze commentedon Nov 3, 2022
Well that is a problem.
As i also have
class Provider implements IProviderbut the documentation of search has no@UseSessionhttps://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/search.html
juliusknorr commentedon Nov 3, 2022
But why would search need to write the session?
the-djmaze commentedon Nov 3, 2022
Because of the horrible Impersonate app.
My SnappyMail app has an automatic login system.
When user logs in Nextcloud it stores password encrypted in the session.
When doing a unified search or open the app, it tries to login.
When login succeeds:
Now the impersonate app is used and you impersonate someone:
To prevent this, i want to:
If the impersonate app properly triggers the
logoutevent OR Nextcloud then all these checks were not needed.the-djmaze commentedon Nov 3, 2022
I know that you want to close the session immediately.
Else there will be a lock on the data and simultaneous requests have to wait for the unlock.
However, with simultaneous requests there are issues:
As this issue is always there, a different approach to sessions could be written.
juliusknorr commentedon Nov 3, 2022
Ok, so for Nextcloud 25 there would be a way to reopen the session with #32162
Now I don't have much insight into the impersonate app but with the described behavior I would imagine this also has all kind of issues with external storages where the login data is stored in the session and probably other session-related cases.
Maybe @blizzz has any further insight as the main contributor to the impersonate app?
the-djmaze commentedon Nov 3, 2022
Yes that would be better.
As for Nextcloud my approach for sessions might be easy to implement to improve #32162
This approach has more IOPS when setting multiple.
So the
->close()could also be done by process/app itself.This way the session:
This would also solve my problem if the Impersonate (or other app) provides similar issues.
Then i can write to Session any time i want and (auto)->close() to unlock asap
the-djmaze commentedon Nov 3, 2022
Oh never mind my response. I looked at the first code but the real solution was later on in the thread.
You all did what i mention using the $this->reopen() 👍
I will use that if Impersonate can't solve this.