Bug #81915
closedWebsite content is deleted when trying to translate a record that contains a field (type=inline) with foreign_table=tt_content and no MM table but foreign_field instead
100%
Description
The issue was discovered using News Extension (news) Version 6.0.0
Background/steps to reproduce:
- basic installation of the latest Typo3 8 version (8.7.3).
- some pages with any content
- add some website languages
- a news directory page with alternative page languages
- add a news item and in the Content Elements tab add some records
- when trying to translate the news ,almost all the content elements from the pages gets deleted
Reason: when trying to synchronize the translated record the following trace is made:
TYPO3\\CMS\\Core\\DataHandling\\DataHandler->localize()
TYPO3\\CMS\\Core\\DataHandling\\DataHandler->copyRecord()
TYPO3\\CMS\\Core\\DataHandling\\DataHandler->process_datamap()
TYPO3\\CMS\\Core\\DataHandling\\Localization\\DataMapProcessor->process()
TYPO3\\CMS\\Core\\DataHandling\\Localization\\DataMapProcessor->enrich()
TYPO3\\CMS\\Core\\DataHandling\\Localization\\DataMapProcessor->synchronizeTranslationItem()
TYPO3\\CMS\\Core\\DataHandling\\Localization\\DataMapProcessor->synchronizeFieldValues()
TYPO3\\CMS\\Core\\DataHandling\\Localization\\DataMapProcessor->synchronizeInlineRelations()
Here (synchronizeInlineRelations()) the class TYPO3\CMS\Core\Database\*RelationHandler* is used to retrieve the news related content elements
In the method TYPO3\CMS\Core\Database\RelationHandler->readForeignField($uid,$conf) which is called at some point the uid is casted to integer.
The issue is that the translation record $uid is a string like "NEW596e1c7328818477389929" and it will be casted to 0.
The query will then return all the records from the tt_content table (all that have value 0 in the foreign_field field - "tx_news_related_news" ).
Returning to the synchronizeInlineRelations() method, the array $removeIds will contain the ids of tt_content elements that are not related to the news record and will get deleted.