Skip to content

Commit 8657956

Browse files
committed
Fix HydratorFactory about nullable date field
1 parent 9b4e9a7 commit 8657956

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,13 @@ private function generateHydratorClass(ClassMetadata $class, string $hydratorCla
185185
<<<'EOF'
186186
187187
// Field(type: "date")
188-
if (isset($data['%1$s'])) {
188+
if (isset($data['%1$s']) || (! empty($this->class->fieldMappings['%2$s']['nullable']) && array_key_exists('%1$s', $data))) {
189189
$value = $data['%1$s'];
190190
%3$s
191-
$this->class->reflFields['%2$s']->setValue($document, clone $return);
191+
if (\is_object($return)) {
192+
$return = clone $return;
193+
}
194+
$this->class->reflFields['%2$s']->setValue($document, $return);
192195
$hydratedData['%2$s'] = $return;
193196
}
194197

0 commit comments

Comments
 (0)