[BUGFIX] DBAL: Set allowNull for insert and update queries to TRUE 01/37701/2
authorArmin Ruediger Vieweg <armin@v.ieweg.de>
Sat, 31 Jan 2015 22:03:24 +0000 (23:03 +0100)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Tue, 10 Mar 2015 14:29:11 +0000 (15:29 +0100)
When DBAL is installed, it was not possible to save NULL values to database, but
TCA fields with mode=useOrOverridePlaceholder fields strongly requires this.
Without the possibility to store NULL to database, "useOrOverridePlaceholder"
would always override the original value.

Resolves: #63991
Releases: master, 6.2
Change-Id: I23cd221431ba9d00e588942bc7c7030e9af805dc
Reviewed-on: http://review.typo3.org/37701
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
typo3/sysext/dbal/Classes/Database/DatabaseConnection.php

index 3751b30..a58e1ef 100644 (file)
@@ -496,7 +496,7 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
                                        $new_id = $this->sql_insert_id();
                                        $where = $this->cache_autoIncFields[$table] . '=' . $new_id;
                                        foreach ($this->lastQuery[1] as $field => $content) {
-                                               $stmt = 'UPDATE ' . $this->quoteFromTables($table) . ' SET ' . $this->quoteFromTables($field) . '=' . $this->fullQuoteStr($content, $table) . ' WHERE ' . $this->quoteWhereClause($where);
+                                               $stmt = 'UPDATE ' . $this->quoteFromTables($table) . ' SET ' . $this->quoteFromTables($field) . '=' . $this->fullQuoteStr($content, $table, TRUE) . ' WHERE ' . $this->quoteWhereClause($where);
                                                $this->query($stmt);
                                        }
                                }
@@ -665,7 +665,7 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
                                } else {
                                        $sqlResult = $this->query($this->lastQuery[0]);
                                        foreach ($this->lastQuery[1] as $field => $content) {
-                                               $stmt = 'UPDATE ' . $this->quoteFromTables($table) . ' SET ' . $this->quoteFromTables($field) . '=' . $this->fullQuoteStr($content, $table) . ' WHERE ' . $this->quoteWhereClause($where);
+                                               $stmt = 'UPDATE ' . $this->quoteFromTables($table) . ' SET ' . $this->quoteFromTables($field) . '=' . $this->fullQuoteStr($content, $table, TRUE) . ' WHERE ' . $this->quoteWhereClause($where);
                                                $this->query($stmt);
                                        }
                                }
@@ -1036,7 +1036,7 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
                                } elseif ($mt[0] == 'F') {
                                        $v = (double) $v;
                                }
-                               $nArr[$this->quoteFieldNames($k)] = !in_array($k, $no_quote_fields) ? $this->fullQuoteStr($v, $table) : $v;
+                               $nArr[$this->quoteFieldNames($k)] = !in_array($k, $no_quote_fields) ? $this->fullQuoteStr($v, $table, TRUE) : $v;
                        }
                }
                if (count($blobFields) || count($clobFields)) {
@@ -1148,7 +1148,7 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
                                                } elseif ($mt[0] == 'F') {
                                                        $v = (double) $v;
                                                }
-                                               $nArr[] = $this->quoteFieldNames($k) . '=' . (!in_array($k, $no_quote_fields) ? $this->fullQuoteStr($v, $table) : $v);
+                                               $nArr[] = $this->quoteFieldNames($k) . '=' . (!in_array($k, $no_quote_fields) ? $this->fullQuoteStr($v, $table, TRUE) : $v);
                                        }
                                }
                        }