From 149e5ad3d07f3babb08fb9a1e6a8b6f224d3640b Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 27 Oct 2026 16:24:35 +0100 Subject: [PATCH 1/2] fix(backend): tell users their mind map was not saved When saving a mind map threw an unexpected exception, the response showed the file's path as the error, a leftover from debugging. Users now read that the mind map could not be saved and should try again later, and the exception is logged, so admins can find out what went wrong. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger (cherry picked from commit ced3a4dfb0dff032f70839f75f9f73ddd42e014c) Signed-off-by: Andy Scherzinger --- lib/Controller/FileHandlingController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Controller/FileHandlingController.php b/lib/Controller/FileHandlingController.php index 43d601fd..d9d77260 100644 --- a/lib/Controller/FileHandlingController.php +++ b/lib/Controller/FileHandlingController.php @@ -175,8 +175,8 @@ public function save($path, $filecontents, $mtime) { $message = (string)$e->getHint(); return new DataResponse(['message' => $message], Http::STATUS_BAD_REQUEST); } catch (\Exception $e) { - $message = (string)$this->l->t('An internal server error occurred.'); - $message = $path; + $this->logger->error('Could not save mind map: ' . $path, ['app' => 'files_mindmap', 'exception' => $e]); + $message = (string)$this->l->t('The mind map could not be saved. Please try again later.'); return new DataResponse(['message' => $message], Http::STATUS_BAD_REQUEST); } } From 6bac3012c26241ebb7d4c05dfeb7bfc63225fcea Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 27 Oct 2026 16:24:52 +0100 Subject: [PATCH 2/2] fix(backend): ask users to reload when a save lacks the file's mtime A save request without the modification time of the loaded file was compared against the file's mtime and failed with "The file you are working on was updated in the meantime", which sent users looking for a conflict that did not exist. Both the user and the public share controller now tell users that the mind map could not be saved and to reload it, which fetches a fresh modification time, and log the request for admins. The branch that was meant to handle this could never be reached and is gone, and log entries from the save endpoint are no longer attributed to files_texteditor. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger (cherry picked from commit 5a793cf9048d946c0950e969841eb89ec7a0c874) Signed-off-by: Andy Scherzinger --- lib/Controller/FileHandlingController.php | 11 ++++++----- lib/Controller/PublicFileHandlingController.php | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/Controller/FileHandlingController.php b/lib/Controller/FileHandlingController.php index d9d77260..6ea3c6f3 100644 --- a/lib/Controller/FileHandlingController.php +++ b/lib/Controller/FileHandlingController.php @@ -136,6 +136,10 @@ public function save($path, $filecontents, $mtime) { } if($file->isUpdateable()) { + if (empty($mtime)) { + $this->logger->error('Save request without the modification time of the loaded file: ' . $path, ['app' => 'files_mindmap']); + return new DataResponse(['message' => $this->l->t('The mind map could not be saved. Please reload it and try again.')], Http::STATUS_BAD_REQUEST); + } if ($mtime != $file->getMTime()) { $this->logger->error("User cannot save shared mind map (someone updated it in the meantime): {$mtime} vs. {$file->getMTime()} {$file->getPath()}", ['app' => 'files_mindmap']); return new DataResponse([ 'message' => $this->l->t('The file you are working on was updated in the meantime. You cannot save your progress as saving would overwrite these changes. Please reload the page.')],Http::STATUS_BAD_REQUEST); @@ -159,16 +163,13 @@ public function save($path, $filecontents, $mtime) { } else { // Not writeable! $this->logger->error('User does not have permission to write to file: ' . $path, - ['app' => 'files_texteditor']); + ['app' => 'files_mindmap']); return new DataResponse([ 'message' => $this->l->t('Insufficient permissions')], Http::STATUS_BAD_REQUEST); } - } else if ($path === '') { + } else { $this->logger->error('No file path supplied'); return new DataResponse(['message' => $this->l->t('File path not supplied')], Http::STATUS_BAD_REQUEST); - } else { - $this->logger->error('No file mtime supplied', ['app' => 'files_texteditor']); - return new DataResponse(['message' => $this->l->t('File mtime not supplied')], Http::STATUS_BAD_REQUEST); } } catch (HintException $e) { diff --git a/lib/Controller/PublicFileHandlingController.php b/lib/Controller/PublicFileHandlingController.php index d575efcb..0b64ce2e 100644 --- a/lib/Controller/PublicFileHandlingController.php +++ b/lib/Controller/PublicFileHandlingController.php @@ -207,6 +207,10 @@ public function save($token, $filecontents, $path, $mtime) { } if(($file instanceof File) && $file->isUpdateable()) { + if (empty($mtime)) { + $this->logger->error('Save request without the modification time of the loaded file: ' . $file->getPath(), ['app' => 'files_mindmap']); + return new DataResponse(['message' => $this->l->t('The mind map could not be saved. Please reload it and try again.')], Http::STATUS_BAD_REQUEST); + } if ($mtime != $file->getMTime()) { $this->logger->error("Anonymous cannot save shared mind map (someone updated it in the meantime): {$mtime} vs. {$file->getMTime()} {$file->getPath()}", ['app' => 'files_mindmap']); return new DataResponse([ 'message' => $this->l->t('The file you are working on was updated in the meantime. You cannot save your progress as saving would overwrite these changes. Please reload the page.')],Http::STATUS_BAD_REQUEST);