[BUGFIX] TCA field using MM table is incorrectly duplicates relations 78/51978/4
authorGeorg Ringer <georg.ringer@gmail.com>
Tue, 7 Mar 2017 18:07:31 +0000 (19:07 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 20 Mar 2017 09:45:15 +0000 (10:45 +0100)
The previous change disabled the lookup on the parent UID which resulted
in getting all possible relations due to the missing constraint. Now the
behavior is mitigated by resetting non-numeric values to zero which will
lead to an empty result set - like implicitly for MySQL before.

Resolved: #80172
Releases: master
Change-Id: If6c8d2e3b2c2b2ddf15727196f7da294fe2ada06
Reviewed-on: https://review.typo3.org/51978
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Thomas Hohn <thomas@hohn.dk>
Tested-by: Thomas Hohn <thomas@hohn.dk>
Reviewed-by: Marcus Schwemer <ms@schwemer.de>
Tested-by: Marcus Schwemer <ms@schwemer.de>
Reviewed-by: Markus Sommer <markussom@posteo.de>
Tested-by: Markus Sommer <markussom@posteo.de>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/core/Classes/Database/RelationHandler.php

index 913dce3..3323d70 100644 (file)
@@ -573,14 +573,12 @@ class RelationHandler
                 $queryBuilder->expr()->eq($field, $queryBuilder->createNamedParameter($value, \PDO::PARAM_STR))
             );
         }
-        if (MathUtility::canBeInterpretedAsInteger($uid)) {
-            $queryBuilder->andWhere(
-                $queryBuilder->expr()->eq(
-                    $uidLocal_field,
-                    $queryBuilder->createNamedParameter((int)$uid, \PDO::PARAM_INT)
-                )
-            );
-        }
+        $queryBuilder->andWhere(
+            $queryBuilder->expr()->eq(
+                $uidLocal_field,
+                $queryBuilder->createNamedParameter((int)$uid, \PDO::PARAM_INT)
+            )
+        );
         $queryBuilder->orderBy($sorting_field);
         $statement = $queryBuilder->execute();
         while ($row = $statement->fetch()) {