[BUGFIX] Incorrect handler detected with DELETE, INSERT and UPDATE
authorJigal van Hemert <jigal@xs4all.nl>
Sat, 30 Jul 2011 13:33:38 +0000 (15:33 +0200)
committerXavier Perseguers <typo3@perseguers.ch>
Sat, 30 Jul 2011 13:36:57 +0000 (15:36 +0200)
exec_DELETEquery(), exec_INSERTquery() and exec_UPDATEquery() (maybe others too) fail
to use the correct handler. exec_SELECTquery() and exec_SELECTgetRows() work correctly
when used with an extra MySQL database, but it is suspected to fail when using a
different DBMS.

Change-Id: I1d1c607ae7dc294feb621aff2b70a205b02b14b0
Fixes: #28563
Releases: 4.5, 4.6

typo3/sysext/dbal/class.ux_t3lib_db.php

index 43582ed..9b3cc6b 100644 (file)
@@ -344,7 +344,7 @@ class ux_t3lib_DB extends t3lib_DB {
                        }
                }
                // Select API:
-               $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+               $this->lastHandlerKey = $this->handler_getFromTableList($table);
                $hType = (string) $this->handlerCfg[$this->lastHandlerKey]['type'];
                switch ($hType) {
                        case 'native':
@@ -526,7 +526,7 @@ class ux_t3lib_DB extends t3lib_DB {
                }
 
                // Select API
-               $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+               $this->lastHandlerKey = $this->handler_getFromTableList($table);
                $hType = (string) $this->handlerCfg[$this->lastHandlerKey]['type'];
                switch ($hType) {
                        case 'native':
@@ -620,7 +620,7 @@ class ux_t3lib_DB extends t3lib_DB {
                }
 
                // Select API
-               $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+               $this->lastHandlerKey = $this->handler_getFromTableList($table);
                $hType = (string) $this->handlerCfg[$this->lastHandlerKey]['type'];
                switch ($hType) {
                        case 'native':
@@ -686,7 +686,13 @@ class ux_t3lib_DB extends t3lib_DB {
                }
 
                // Get handler key and select API:
-               $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+               if (count($remappedParameters) > 0) {
+                       $mappedQueryParts = $this->compileSelectParameters($remappedParameters);
+                       $fromTable = $mappedQueryParts[1];
+               } else {
+                       $fromTable = $from_table;
+               }
+               $this->lastHandlerKey = $this->handler_getFromTableList($fromTable);
                $hType = (string) $this->handlerCfg[$this->lastHandlerKey]['type'];
                switch ($hType) {
                        case 'native':
@@ -783,7 +789,7 @@ class ux_t3lib_DB extends t3lib_DB {
                }
 
                // Select API
-               $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+               $this->lastHandlerKey = $this->handler_getFromTableList($table);
                $hType = (string) $this->handlerCfg[$this->lastHandlerKey]['type'];
                switch ($hType) {
                        case 'native':
@@ -2665,7 +2671,7 @@ class ux_t3lib_DB extends t3lib_DB {
                }
 
                // Find columns
-               $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+               $this->lastHandlerKey = $this->handler_getFromTableList($tableName);
                switch ((string) $this->handlerCfg[$this->lastHandlerKey]['type']) {
                        case 'native':
                                $columns_res = mysql_query('SHOW columns FROM ' . $tableName, $this->handlerInstance[$this->lastHandlerKey]['link']);
@@ -2734,7 +2740,7 @@ class ux_t3lib_DB extends t3lib_DB {
                }
 
                // Find columns
-               $this->lastHandlerKey = $this->handler_getFromTableList($ORIG_tableName);
+               $this->lastHandlerKey = $this->handler_getFromTableList($tableName);
                switch ((string) $this->handlerCfg[$this->lastHandlerKey]['type']) {
                        case 'native':
                                $keyRes = mysql_query('SHOW keys FROM ' . $tableName, $this->handlerInstance[$this->lastHandlerKey]['link']);