Skip to content

Commit 26a3e91

Browse files
committed
Fix callable nullness
1 parent 6bff126 commit 26a3e91

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

src/Database/Database.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,8 +3533,7 @@ public function createDocuments(
35333533
if ($this->resolveRelationships) {
35343534
$document = $this->silent(fn () => $this->populateDocumentRelationships($collection, $document));
35353535
}
3536-
3537-
$onNext($document);
3536+
$onNext && $onNext($document);
35383537
$modified++;
35393538
}
35403539
}
@@ -4230,7 +4229,7 @@ public function updateDocuments(
42304229
$this->purgeCachedDocument($collection->getId(), $document->getId());
42314230
}
42324231

4233-
$onNext($document);
4232+
$onNext && $onNext($document);
42344233
$modified++;
42354234
}
42364235

@@ -4809,7 +4808,7 @@ public function createOrUpdateDocumentsWithIncrease(
48094808
$this->purgeCachedDocument($collection->getId(), $document->getId());
48104809
}
48114810

4812-
$onNext($document);
4811+
$onNext && $onNext($document);
48134812
$modified++;
48144813
}
48154814
}
@@ -5594,7 +5593,7 @@ public function deleteDocuments(
55945593
$this->purgeCachedDocument($collection->getId(), $document->getId());
55955594
}
55965595

5597-
$onNext($document);
5596+
$onNext && $onNext($document);
55985597
$modified++;
55995598
}
56005599

src/Database/Mirror.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ public function createDocuments(
561561
$documents,
562562
$batchSize,
563563
function ($doc) use ($onNext, &$modified) {
564-
$onNext($doc);
564+
$onNext && $onNext($doc);
565565
$modified++;
566566
},
567567
);
@@ -575,10 +575,6 @@ function ($doc) use ($onNext, &$modified) {
575575

576576
$upgrade = $this->silent(fn () => $this->getUpgradeStatus($collection));
577577
if ($upgrade === null || $upgrade->getAttribute('status', '') !== 'upgraded') {
578-
foreach ($documents as $document) {
579-
$onNext($document);
580-
}
581-
582578
return $modified;
583579
}
584580

@@ -690,7 +686,7 @@ public function updateDocuments(
690686
$queries,
691687
$batchSize,
692688
function ($doc) use ($onNext, &$modified) {
693-
$onNext($doc);
689+
$onNext && $onNext($doc);
694690
$modified++;
695691
}
696692
);
@@ -803,7 +799,7 @@ public function deleteDocuments(
803799
$queries,
804800
$batchSize,
805801
function ($doc) use (&$modified, $onNext) {
806-
$onNext($doc);
802+
$onNext && $onNext($doc);
807803
$modified++;
808804
},
809805
);

0 commit comments

Comments
 (0)