@@ -5376,7 +5376,7 @@ public function deleteDocuments(string $collection, array $queries = [], int $ba
53765376 $ cursor = $ grouped ['cursor ' ];
53775377
53785378 if (!empty ($ cursor ) && $ cursor ->getCollection () !== $ collection ->getId ()) {
5379- throw new DatabaseException ("cursor Document must be from the same Collection. " );
5379+ throw new DatabaseException ("Cursor document must be from the same Collection. " );
53805380 }
53815381
53825382 $ documents = $ this ->withTransaction (function () use ($ collection , $ queries , $ batchSize , $ limit , $ cursor ) {
@@ -5413,12 +5413,14 @@ public function deleteDocuments(string $collection, array $queries = [], int $ba
54135413 break ;
54145414 }
54155415
5416- $ documents = array_merge ($ affectedDocuments , $ documents );
5416+ $ documents = \ array_merge ($ affectedDocuments , $ documents );
54175417
54185418 foreach ($ affectedDocuments as $ document ) {
5419- // Delete Relationships
54205419 if ($ this ->resolveRelationships ) {
5421- $ document = $ this ->silent (fn () => $ this ->deleteDocumentRelationships ($ collection , $ document ));
5420+ $ document = $ this ->silent (fn () => $ this ->deleteDocumentRelationships (
5421+ $ collection ,
5422+ $ document
5423+ ));
54225424 }
54235425
54245426 // Check if document was updated after the request timestamp
@@ -5431,8 +5433,6 @@ public function deleteDocuments(string $collection, array $queries = [], int $ba
54315433 if (!\is_null ($ this ->timestamp ) && $ oldUpdatedAt > $ this ->timestamp ) {
54325434 throw new ConflictException ('Document was updated after the request timestamp ' );
54335435 }
5434-
5435- $ this ->purgeCachedDocument ($ collection ->getId (), $ document ->getId ());
54365436 }
54375437
54385438 if (count ($ affectedDocuments ) < $ batchSize ) {
@@ -5448,11 +5448,6 @@ public function deleteDocuments(string $collection, array $queries = [], int $ba
54485448 return [];
54495449 }
54505450
5451- $ this ->trigger (self ::EVENT_DOCUMENTS_DELETE , new Document ([
5452- '$collection ' => $ collection ->getId (),
5453- 'modified ' => count ($ documents )
5454- ]));
5455-
54565451 foreach (\array_chunk ($ documents , $ batchSize ) as $ chunk ) {
54575452 $ this ->adapter ->deleteDocuments (
54585453 $ collection ->getId (),
@@ -5463,6 +5458,15 @@ public function deleteDocuments(string $collection, array $queries = [], int $ba
54635458 return $ documents ;
54645459 });
54655460
5461+ foreach ($ documents as $ document ) {
5462+ $ this ->purgeCachedDocument ($ collection ->getId (), $ document ->getId ());
5463+ }
5464+
5465+ $ this ->trigger (self ::EVENT_DOCUMENTS_DELETE , new Document ([
5466+ '$collection ' => $ collection ->getId (),
5467+ 'modified ' => count ($ documents )
5468+ ]));
5469+
54665470 return $ documents ;
54675471 }
54685472
0 commit comments