Skip to content

Commit

Permalink
[FEATURE] fe-data-history-3 Problem when removing a FileReference
Browse files Browse the repository at this point in the history
Tasks:
* add check if oldValue is in fact a reference

Resolves: #3
  • Loading branch information
foppelfb committed Sep 18, 2023
1 parent a3a68a8 commit bbf4dd0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Classes/Traits/HistoryRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use TYPO3\CMS\Extbase\Persistence\Generic\Exception\TooDirtyException;
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use function get_class;

/**
* Class HistoryRecord
Expand Down Expand Up @@ -88,7 +89,8 @@ protected function writeModified(DomainObjectInterface $object)
$oldRecord[$dbProperty] = ($object->_getCleanProperty($property) ? $object->_getCleanProperty($property)->getUid() : null);
$newRecord[$dbProperty] = $value->getUid();
} else {
$oldRecord[$dbProperty] = $object->_getCleanProperty($property);
$oldValue = $object->_getCleanProperty($property);
$oldRecord[$dbProperty] = $oldValue instanceof AbstractEntity ? $oldValue->getUid() : (int)$oldValue;
$newRecord[$dbProperty] = $value;
}
}
Expand Down Expand Up @@ -149,7 +151,7 @@ protected function writeDeleted(DomainObjectInterface $object)
*/
private function getTableName(DomainObjectInterface $obj): string
{
return $this->dataMapper->getDataMap(\get_class($obj))->getTableName();
return $this->dataMapper->getDataMap( get_class($obj))->getTableName();
}

/**
Expand All @@ -159,6 +161,6 @@ private function getTableName(DomainObjectInterface $obj): string
*/
private function getDbFieldName(string $property, DomainObjectInterface $obj): string
{
return $this->dataMapper->convertPropertyNameToColumnName($property, \get_class($obj));
return $this->dataMapper->convertPropertyNameToColumnName($property, get_class($obj));
}
}

0 comments on commit bbf4dd0

Please sign in to comment.