From 335389a6e354b92e959c2fc40e35f5804b03f75d Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Sat, 19 Dec 2020 11:27:46 +0100 Subject: [PATCH] [BUGFIX] SQL error in some MM workspaces discard scenarios Depending on SQL structure of an MM table, the recent fix for issue #93064 can lead to query errors: It works with core category relations but fails for instance with ext:news 'related news' relations. This is due to an assumption about existence of field 'tablenames', which is bogus. If needed, the according where restriction comes from TCA MM_match_fields already, which is sufficient. Resolves: #93109 Related: #93064 Releases: master, 10.4 Change-Id: Ifcc15989f87119cfb10c2da47c22b42a0dd4558a Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67188 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: Sebastian Michaelsen <michaelsen@t3seo.de> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Sebastian Michaelsen <michaelsen@t3seo.de> Reviewed-by: Benni Mack <benni@typo3.org> --- typo3/sysext/core/Classes/DataHandling/DataHandler.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index f6b0e41a0c93..4df387b25a0e 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -5359,14 +5359,6 @@ class DataHandler implements LoggerAwareInterface // uid_local = given uid OR uid_foreign = given uid $queryBuilder->expr()->eq($relationUidFieldName, $queryBuilder->createNamedParameter($recordUid, \PDO::PARAM_INT)) ); - if ($relationUidFieldName === 'uid_foreign') { - // When discarding a local-side record - eg. sys_category - it does not matter who points to it, - // all relations can be dropped. If on foreign side - eg. tt_content to sys_category - "tablenames" - // field has to be taken into account to not delete rows with same uid from other tables. - $queryBuilder->andWhere( - $queryBuilder->expr()->eq('tablenames', $queryBuilder->createNamedParameter($table, \PDO::PARAM_STR)) - ); - } if (!empty($fieldConfig['MM_table_where']) && is_string($fieldConfig['MM_table_where'])) { $queryBuilder->andWhere( QueryHelper::stripLogicalOperatorPrefix(str_replace('###THIS_UID###', (string)$recordUid, $fieldConfig['MM_table_where'])) -- GitLab