Skip to content

Commit 0d0d7a1

Browse files
Merge pull request #8764 from nextcloud/backport/8754/stable34
[stable34] Performance: Only check permissions when changing content
2 parents 9bfb2cf + a8a79ac commit 0d0d7a1

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

lib/Service/DocumentService.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,11 @@ public function writeDocumentState(int $documentId, string $content): void {
218218
*/
219219
public function addStep(Document $document, Session $session, array $steps, int $version, ?int $recoveryAttempt, ?string $shareToken): array {
220220
$documentId = $session->getDocumentId();
221-
$file = $this->getFileForSession($session, $shareToken);
222-
$readOnly = $this->isReadOnly($file, $shareToken);
223221
$stepsToInsert = [];
224222
$stepsIncludeQuery = false;
225223
$documentState = null;
226224
foreach ($steps as $step) {
227225
$message = YjsMessage::fromBase64($step);
228-
if ($readOnly && $message->isUpdate()) {
229-
continue;
230-
}
231226
// Only accept sync protocol
232227
if ($message->getYjsMessageType() !== YjsMessage::YJS_MESSAGE_SYNC) {
233228
continue;
@@ -240,10 +235,10 @@ public function addStep(Document $document, Session $session, array $steps, int
240235
}
241236
}
242237
if (count($stepsToInsert) > 0) {
243-
if ($readOnly) {
244-
throw new NotPermittedException('Read-only client tries to push steps with changes');
238+
$file = $this->getFileForSession($session, $shareToken);
239+
if (!$this->isReadOnly($file, $shareToken)) {
240+
$this->insertSteps($document, $session, $stepsToInsert);
245241
}
246-
$this->insertSteps($document, $session, $stepsToInsert);
247242
}
248243

249244
// By default, send all steps the user has not received yet.

0 commit comments

Comments
 (0)