From a1ca5180d383c7daf9f15114742048568ffc913b Mon Sep 17 00:00:00 2001 From: Armin Ruediger Vieweg <armin@v.ieweg.de> Date: Sat, 31 Jan 2015 23:03:24 +0100 Subject: [PATCH] [BUGFIX] DBAL: Set allowNull for insert and update queries to TRUE 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/36545 Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de> Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de> 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/typo3/sysext/dbal/Classes/Database/DatabaseConnection.php b/typo3/sysext/dbal/Classes/Database/DatabaseConnection.php index 97ec7a314825..52ffd689e16e 100644 --- a/typo3/sysext/dbal/Classes/Database/DatabaseConnection.php +++ b/typo3/sysext/dbal/Classes/Database/DatabaseConnection.php @@ -495,7 +495,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); } } @@ -664,7 +664,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); } } } -- GitLab