-
Notifications
You must be signed in to change notification settings - Fork 111
fix: load fresh session if none are remaining #3890
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,12 +113,12 @@ public function create($fileId = null, $filePath = null, $token = null, $guestNa | |
| $readOnly = $this->documentService->isReadOnly($file, $token); | ||
|
|
||
| $this->sessionService->removeInactiveSessions($file->getId()); | ||
| $activeSessions = $this->sessionService->getActiveSessions($file->getId()); | ||
| $remainingSessions = $this->sessionService->getAllSessions($file->getId()); | ||
| $freshSession = false; | ||
| if ($forceRecreate || count($activeSessions) === 0) { | ||
| if ($forceRecreate || count($remainingSessions) === 0) { | ||
| $freshSession = true; | ||
| try { | ||
| $this->documentService->resetDocument($file->getId(), $forceRecreate); | ||
| $freshSession = true; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly, this means that we always start a fresh session here, also if
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right - that's exactly what this change is aiming for. Let me explain the reasoning in more detail. We would not need the session to apply the steps - they are self contained - as long as all of them are present. However if the session does not exist anymore it must have been removed. If steps are still present this only happens during a close call. So close was called on the session. If other sessions are still around we won't run into this block anyway. If there were other sessions around during the close they would have been closed as well and would have cleaned up the steps. Therefore if we end up here the session must have been the last active session when it was closed. In that case it will have cleaned up it's steps and the remaining unsaved changes are just leftovers from the race condition and yes... we cannot apply them anymore because we lack the history leading up to them. |
||
| } catch (DocumentHasUnsavedChangesException $e) { | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand the impact of this change: we only create a fresh session now if "no session was found", instead of "no active session was found" before, right? So we will always try to restore sessions, even if they're not active anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Sessions become inactive after 5 minutes. But there may still be steps that were created during the session but never persisted. All the cleanup functions will leave those steps and their session in place (unless
forceReloadis set). This change makes it so we still recover these changes after more than 5 minutes.