Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/Database/Database.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -4275,6 +4275,9 @@ public function updateDocument(string $collection, string $id, Document $documen
$old = Authorization::skip(fn () => $this->silent(
fn () => $this->getDocument($collection->getId(), $id, forUpdate: true)
));
if ($old->isEmpty()) {
return new Document();
}

$skipPermissionsUpdate = true;

Expand DownExpand Up@@ -4414,10 +4417,6 @@ public function updateDocument(string $collection, string $id, Document $documen
}
}

if ($old->isEmpty()) {
return new Document();
}

if ($shouldUpdate) {
$document->setAttribute('$updatedAt', ($newUpdatedAt === null || !$this->preserveDates) ? $time : $newUpdatedAt);
}
Expand DownExpand Up@@ -4450,6 +4449,10 @@ public function updateDocument(string $collection, string $id, Document $documen
return $document;
});

if ($document->isEmpty()) {
return $document;
}

if ($this->resolveRelationships) {
$document = $this->silent(fn () => $this->populateDocumentRelationships($collection, $document));
}
Expand DownExpand Up@@ -5573,7 +5576,9 @@ public function deleteDocument(string $collection, string $id): bool
return $result;
});

$this->trigger(self::EVENT_DOCUMENT_DELETE, $document);
if ($deleted) {
$this->trigger(self::EVENT_DOCUMENT_DELETE, $document);
}

return $deleted;
}
Expand Down