Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Respect soft delete feature for records #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Classes/Mapping/AbstractMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,17 @@ protected function importObjectWithDimensionMappings(array $data, $object, Event
$GLOBALS['TSFE']->config['sys_language_uid'] = 0;
$GLOBALS['TSFE']->settingLanguage();

// the soft delete feature needs to be taken into account, otherwise a deleted record might be updated
// and thus will not have any effect in the frontend and backend
$softDeleteField = $this->getSoftDeleteFieldForTable($this->getTableName());
if ($softDeleteField !== '') {
$softDeleteField = ' AND ' . $softDeleteField . ' = 0';
}

$existingRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
'uid,l10n_parent,sys_language_uid',
$this->getTableName(),
'sys_language_uid = ' . $languageUid . ' AND l10n_parent = ' . $object->getUid()
'sys_language_uid = ' . $languageUid . ' AND l10n_parent = ' . $object->getUid() . $softDeleteField
);

$translationObject = $this->createObject($event, $languageUid, $object->getUid(), $existingRow);
Expand All @@ -832,6 +839,14 @@ protected function importObjectWithDimensionMappings(array $data, $object, Event
return $mappingProblemsOccurred;
}

protected function getSoftDeleteFieldForTable(string $tablename): string
{
if (! empty($GLOBALS['TCA'][$tablename]['ctrl']['delete'])) {
return $GLOBALS['TCA'][$tablename]['ctrl']['delete'];
}
return '';
}

protected function logProblem($message)
{
GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__)->alert($message);
Expand Down