[BUGFIX] Respect table mapping on caching 74/27874/8
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 26 Feb 2014 15:51:37 +0000 (16:51 +0100)
committerXavier Perseguers <xavier@typo3.org>
Tue, 18 Mar 2014 15:25:51 +0000 (16:25 +0100)
The method analyzeFields() of DBAL's DatabaseConnection caches the
table structure. The cache always uses the real table name, ignoring
any mapping, which results in a RuntimeException:

"Could not update BLOB >>>> no WHERE clause found!"

The method now checks for a possible mapping and sets the alias
as table name.

Resolves: #56349
Releases: 6.2
Change-Id: I9599cebc8604103c3749bc142cd44b813f018a72
Reviewed-on: https://review.typo3.org/27874
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/dbal/Classes/Database/DatabaseConnection.php

index b1aedc3..aa8e0ba 100644 (file)
@@ -365,6 +365,10 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
         */
        protected function analyzeFields($parsedExtSQL) {
                foreach ($parsedExtSQL as $table => $tdef) {
+                       // check if table is mapped
+                       if (isset($this->mapping[$table])) {
+                               $table = $this->mapping[$table]['mapTableName'];
+                       }
                        if (is_array($tdef['fields'])) {
                                foreach ($tdef['fields'] as $field => $fdefString) {
                                        $fdef = $this->SQLparser->parseFieldDef($fdefString);
@@ -2397,10 +2401,6 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
        public function sql_field_metatype($table, $field) {
                // If $table and/or $field are mapped, use the original names instead
                foreach ($this->mapping as $tableName => $tableMapInfo) {
-                       if (isset($tableMapInfo['mapTableName']) && $tableMapInfo['mapTableName'] === $table) {
-                               // Table name is mapped => use original name
-                               $table = $tableName;
-                       }
                        if (isset($tableMapInfo['mapFieldNames'])) {
                                foreach ($tableMapInfo['mapFieldNames'] as $fieldName => $fieldMapInfo) {
                                        if ($fieldMapInfo === $field) {