Commit 335389a6 authored by Christian Kuhn's avatar Christian Kuhn Committed by Benni Mack
Browse files

[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: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarSebastian Michaelsen <michaelsen@t3seo.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: default avatarSebastian Michaelsen <michaelsen@t3seo.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 793fc121
......@@ -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']))
......
Supports Markdown
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