Fix update document merging existing data after pre-processing instead of before
This commit is contained in:
parent
ba24c0a843
commit
2eafda4ee2
1 changed files with 1 additions and 2 deletions
|
@ -3279,6 +3279,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||||
$permissions = $document->getPermissions() ?? [];
|
$permissions = $document->getPermissions() ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data = \array_merge($document->getArrayCopy(), $data); // Merge existing data with new data
|
||||||
$data['$collection'] = $collection->getId(); // Make sure user doesn't switch collectionID
|
$data['$collection'] = $collection->getId(); // Make sure user doesn't switch collectionID
|
||||||
$data['$createdAt'] = $document->getCreatedAt(); // Make sure user doesn't switch createdAt
|
$data['$createdAt'] = $document->getCreatedAt(); // Make sure user doesn't switch createdAt
|
||||||
$data['$id'] = $document->getId(); // Make sure user doesn't switch document unique ID
|
$data['$id'] = $document->getId(); // Make sure user doesn't switch document unique ID
|
||||||
|
@ -3368,8 +3369,6 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||||
|
|
||||||
$checkPermissions($collection, $newDocument, $document, Database::PERMISSION_UPDATE);
|
$checkPermissions($collection, $newDocument, $document, Database::PERMISSION_UPDATE);
|
||||||
|
|
||||||
$newDocument = new Document(\array_merge($document->getArrayCopy(), $data));
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$document = $dbForProject->withRequestTimestamp(
|
$document = $dbForProject->withRequestTimestamp(
|
||||||
$requestTimestamp,
|
$requestTimestamp,
|
||||||
|
|
Loading…
Reference in a new issue