Skip to content

Commit 87a32dd

Browse files
abnegateclaude
andcommitted
(fix): always call castingAfter in createDocument regardless of relationship hook
castingAfter was only called when a Relationships hook was registered, but it's needed unconditionally to convert adapter-specific types (like MongoDB UTCDateTime) to PHP types. Without it, BSON objects leak into document responses. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a32778b commit 87a32dd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Database/Traits/Documents.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,10 @@ public function createDocument(string $collection, Document $document): Document
437437
if ($hook !== null && ! $hook->isInBatchPopulation() && $hook->isEnabled()) {
438438
$fetchDepth = $hook->getWriteStackCount();
439439
$documents = $this->silent(fn () => $hook->populateDocuments([$document], $collection, $fetchDepth));
440-
$document = $this->adapter->castingAfter($collection, $documents[0]);
440+
$document = $documents[0];
441441
}
442442

443+
$document = $this->adapter->castingAfter($collection, $document);
443444
$document = $this->casting($collection, $document);
444445
$document = $this->decode($collection, $document);
445446

0 commit comments

Comments
 (0)