From db956fc5ad294a7995fb4d97cd725580a49958df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Wed, 20 May 2020 23:42:01 +0200 Subject: [PATCH] Fixed the timetravel function for big_decimal fields. --- src/Services/LogSystem/TimeTravel.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Services/LogSystem/TimeTravel.php b/src/Services/LogSystem/TimeTravel.php index 6a5ab500..50ec7076 100644 --- a/src/Services/LogSystem/TimeTravel.php +++ b/src/Services/LogSystem/TimeTravel.php @@ -32,6 +32,7 @@ use App\Entity\Contracts\TimeTravelInterface; use App\Entity\LogSystem\AbstractLogEntry; use App\Entity\LogSystem\CollectionElementDeleted; use App\Entity\LogSystem\ElementEditedLogEntry; +use Brick\Math\BigDecimal; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; @@ -184,6 +185,14 @@ class TimeTravel foreach ($old_data as $field => $data) { if ($metadata->hasField($field)) { + + if ($metadata->getFieldMapping($field)['type'] === 'big_decimal') { + //We need to convert the string to a BigDecimal first + if (!$data instanceof BigDecimal) { + $data = BigDecimal::of($data); + } + } + $this->setField($element, $field, $data); } if ($metadata->hasAssociation($field)) { @@ -217,6 +226,8 @@ class TimeTravel $reflection = new \ReflectionClass(get_class($element)); $property = $reflection->getProperty($field); $property->setAccessible(true); + + $property->setValue($element, $new_value); } }