Skip to content
Snippets Groups Projects
Commit 29dbc2fb authored by Nicole Cordes's avatar Nicole Cordes Committed by Anja Leichsenring
Browse files

[BUGFIX] Remove relations from MM table

If extbase deletes an object it doesn't delete its relations in an
MM table. This patch adds the check for a possible MM relation table and
ensures all relations get deleted as well. If the parent table supports
a deleted flag, no relations will be deleted to be able to restore the
parent record again.

Resolves: #78128
Releases: master, 7.6
Change-Id: Ibe2497c05838e261f9c67a80216385d6e60607cb
Reviewed-on: https://review.typo3.org/50103


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Tested-by: default avatarRobert Jelinek <robert.jelinek@riir.at>
Reviewed-by: default avatarAlexander Stehlik <alexander.stehlik@gmail.com>
Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent a98388be
Branches
Tags
No related merge requests found
......@@ -1092,6 +1092,9 @@ class Backend implements \TYPO3\CMS\Extbase\Persistence\Generic\BackendInterface
$properties = $object->_getProperties();
foreach ($properties as $propertyName => $propertyValue) {
$columnMap = $dataMap->getColumnMap($propertyName);
if ($columnMap === null) {
continue;
}
$propertyMetaData = $classSchema->getProperty($propertyName);
if ($propertyMetaData['cascade'] === 'remove') {
if ($columnMap->getTypeOfRelation() === \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap::RELATION_HAS_MANY) {
......@@ -1101,6 +1104,10 @@ class Backend implements \TYPO3\CMS\Extbase\Persistence\Generic\BackendInterface
} elseif ($propertyValue instanceof \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface) {
$this->removeEntity($propertyValue);
}
} elseif ($dataMap->getDeletedFlagColumnName() === null
&& $columnMap->getTypeOfRelation() === ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY
) {
$this->deleteAllRelationsFromRelationtable($object, $propertyName);
}
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment