[BUGFIX] Prevent crash in DatabaseIntegrityCheck 01/58201/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Thu, 6 Sep 2018 13:57:50 +0000 (15:57 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 7 Sep 2018 15:27:47 +0000 (17:27 +0200)
If a relation field (select / group) does not exist in db for
whatever reason, System -> DB check -> Database relations
crashes.

Resolves: #86167
Releases: master, 8.7
Change-Id: Id6a502d56b985f6410f40a1f547fe7b923e9d982
Reviewed-on: https://review.typo3.org/58201
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Richard Haeser <richard@maxserv.com>
Tested-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Integrity/DatabaseIntegrityCheck.php
typo3/sysext/lowlevel/Classes/Integrity/DatabaseIntegrityCheck.php

index 12667c1..3928151 100644 (file)
@@ -467,6 +467,14 @@ class DatabaseIntegrityCheck
                         // It is quoted for keywords
                         $column = $tableColumns[strtolower($fieldName)]
                             ?? $tableColumns[$connection->quoteIdentifier(strtolower($fieldName))];
+                        if (!$column) {
+                            // Throw meaningful exception if field does not exist in DB - 'none' is not filtered here since the
+                            // method is only called with type=group fields
+                            throw new \RuntimeException(
+                                'Field ' . $fieldName . ' for table ' . $table . ' has been defined in TCA, but does not exist in DB',
+                                1536248936
+                            );
+                        }
                         $fieldType = $column->getType()->getName();
                         if (in_array(
                             $fieldType,
index 301e72c..e95a337 100644 (file)
@@ -463,6 +463,14 @@ class DatabaseIntegrityCheck
                         // It is quoted for keywords
                         $column = $tableColumns[strtolower($fieldName)]
                             ?? $tableColumns[$connection->quoteIdentifier(strtolower($fieldName))];
+                        if (!$column) {
+                            // Throw meaningful exception if field does not exist in DB - 'none' is not filtered here since the
+                            // method is only called with type=group fields
+                            throw new \RuntimeException(
+                                'Field ' . $fieldName . ' for table ' . $table . ' has been defined in TCA, but does not exist in DB',
+                                1536248937
+                            );
+                        }
                         $fieldType = $column->getType()->getName();
                         if (in_array(
                             $fieldType,