From 39956d28c1e58bb97032f51f21dfe6dd882adbcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 22 Nov 2022 18:13:14 +0100 Subject: [PATCH 1/4] Adapt session handling description to changes in Nextcloud 25 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- developer_manual/basics/controllers.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/developer_manual/basics/controllers.rst b/developer_manual/basics/controllers.rst index bac004fca..2286387b1 100644 --- a/developer_manual/basics/controllers.rst +++ b/developer_manual/basics/controllers.rst @@ -220,6 +220,14 @@ Reading and writing session variables To set, get or modify session variables, the ISession object has to be injected into the controller. +Nextcloud will read existing session data at the beginning of the request lifecycle and close the session afterwards. This means that in order to write to the session, the session has to be opened first. This is done implicitly when calling the set method, but would close immidiately afterwards. To prevent this, the session has to be explicitly opened by calling the reopen method. + +Alternatively you can use the UseSession annotation to automatically open and close the session for you. + +In case the session may be read and written by concurrent requests of your application keeping the session open during your controller method execution may be required to ensure that the session is locked and no other request can write to the session at the same time. When reopening the session, the session data will also get updated with the latest changes from other requests. Using the annotation will keep the session lock during the whole time of the controller method execution. + +For additional information on how session locking works in PHP see the artile about `PHP Session Locking: How To Prevent Sessions Blocking in PHP requests `_. + Then session variables can be accessed like this: .. note:: The session is closed automatically for writing, unless you add the @UseSession annotation! From da5ac61f0251431443c2d4ee8f0e388ee071f564 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 14 Dec 2022 22:42:07 +0100 Subject: [PATCH 2/4] Update developer_manual/basics/controllers.rst Co-authored-by: Christoph Wurst Signed-off-by: Daniel --- developer_manual/basics/controllers.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer_manual/basics/controllers.rst b/developer_manual/basics/controllers.rst index 2286387b1..59c47737b 100644 --- a/developer_manual/basics/controllers.rst +++ b/developer_manual/basics/controllers.rst @@ -224,7 +224,7 @@ Nextcloud will read existing session data at the beginning of the request lifecy Alternatively you can use the UseSession annotation to automatically open and close the session for you. -In case the session may be read and written by concurrent requests of your application keeping the session open during your controller method execution may be required to ensure that the session is locked and no other request can write to the session at the same time. When reopening the session, the session data will also get updated with the latest changes from other requests. Using the annotation will keep the session lock during the whole time of the controller method execution. +In case the session may be read and written by concurrent requests of your application, keeping the session open during your controller method execution may be required to ensure that the session is locked and no other request can write to the session at the same time. When reopening the session, the session data will also get updated with the latest changes from other requests. Using the annotation will keep the session lock for the whole duration of the controller method execution. For additional information on how session locking works in PHP see the artile about `PHP Session Locking: How To Prevent Sessions Blocking in PHP requests `_. From b8c80654232e2280c5e06c120abca232fc1415e4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 14 Dec 2022 22:42:13 +0100 Subject: [PATCH 3/4] Update developer_manual/basics/controllers.rst Co-authored-by: Christoph Wurst Signed-off-by: Daniel --- developer_manual/basics/controllers.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer_manual/basics/controllers.rst b/developer_manual/basics/controllers.rst index 59c47737b..ef7156599 100644 --- a/developer_manual/basics/controllers.rst +++ b/developer_manual/basics/controllers.rst @@ -222,7 +222,7 @@ To set, get or modify session variables, the ISession object has to be injected Nextcloud will read existing session data at the beginning of the request lifecycle and close the session afterwards. This means that in order to write to the session, the session has to be opened first. This is done implicitly when calling the set method, but would close immidiately afterwards. To prevent this, the session has to be explicitly opened by calling the reopen method. -Alternatively you can use the UseSession annotation to automatically open and close the session for you. +Alternatively you can use the ``@UseSession`` annotation to automatically open and close the session for you. In case the session may be read and written by concurrent requests of your application, keeping the session open during your controller method execution may be required to ensure that the session is locked and no other request can write to the session at the same time. When reopening the session, the session data will also get updated with the latest changes from other requests. Using the annotation will keep the session lock for the whole duration of the controller method execution. From 48083ef49d899f4822bf6cd5c2cadedccd21b641 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 14 Dec 2022 22:42:19 +0100 Subject: [PATCH 4/4] Update developer_manual/basics/controllers.rst Signed-off-by: Daniel --- developer_manual/basics/controllers.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer_manual/basics/controllers.rst b/developer_manual/basics/controllers.rst index ef7156599..6567b57c3 100644 --- a/developer_manual/basics/controllers.rst +++ b/developer_manual/basics/controllers.rst @@ -220,7 +220,7 @@ Reading and writing session variables To set, get or modify session variables, the ISession object has to be injected into the controller. -Nextcloud will read existing session data at the beginning of the request lifecycle and close the session afterwards. This means that in order to write to the session, the session has to be opened first. This is done implicitly when calling the set method, but would close immidiately afterwards. To prevent this, the session has to be explicitly opened by calling the reopen method. +Nextcloud will read existing session data at the beginning of the request lifecycle and close the session afterwards. This means that in order to write to the session, the session has to be opened first. This is done implicitly when calling the set method, but would close immediately afterwards. To prevent this, the session has to be explicitly opened by calling the reopen method. Alternatively you can use the ``@UseSession`` annotation to automatically open and close the session for you.