Fixed an exception related during undeletion of elements.

This commit is contained in:
Jan Böhmer 2022-09-25 01:14:07 +02:00
parent 9996e2280a
commit 2bd41eee60

View file

@ -39,6 +39,7 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\MappingException;
use DoctrineExtensions\Query\Mysql\Date;
use Exception;
use InvalidArgumentException;
use ReflectionClass;
@ -171,6 +172,17 @@ class TimeTravel
}
}
/**
* This function decodes the array which is created during the json_encode of a datetime object and returns a DateTime object.
* @param array $input
* @return DateTime
* @throws Exception
*/
private function dateTimeDecode(array $input): \DateTime
{
return new \DateTime($input['date'], new \DateTimeZone($input['timezone']));
}
/**
* Apply the changeset in the given LogEntry to the element.
*
@ -195,6 +207,10 @@ class TimeTravel
$data = BigDecimal::of($data);
}
if (!$data instanceof DateTime && ('datetime' === $metadata->getFieldMapping($field)['type'])) {
$data = $this->dateTimeDecode($data);
}
$this->setField($element, $field, $data);
}
if ($metadata->hasAssociation($field)) {