[BUGFIX] Cannot use single quote in TS constant part
authorXavier Perseguers <typo3@perseguers.ch>
Wed, 6 Apr 2011 12:15:45 +0000 (14:15 +0200)
committerXavier Perseguers <typo3@perseguers.ch>
Wed, 6 Apr 2011 12:15:45 +0000 (14:15 +0200)
It is not possible to save a TS template if the constants contain a single quote, when
using recent version of MSSQL (at least with MMSSQL 2008).

Change-Id: I02c9b84d624fe5ac6cba0039826312ab62b844e1
Resolves: #25777

typo3/sysext/dbal/class.tx_dbal_installtool.php
typo3/sysext/dbal/class.ux_t3lib_db.php
typo3/sysext/dbal/tests/fixtures/mssql.config.php

index 705e850..95f66f5 100644 (file)
@@ -137,7 +137,8 @@ class tx_dbal_installtool {
                                                break;
                                        case 'mssql':
                                        case 'odbc_mssql':
-                                               $driverConfig = '\'useNameQuote\' => TRUE';
+                                               $driverConfig = '\'useNameQuote\' => TRUE,'
+                                                               . '\'quoteClob\' => FALSE';
                                                break;
                                        case 'mysql':
                                                return;
index d02da5b..91ec43d 100644 (file)
@@ -177,7 +177,8 @@ class ux_t3lib_DB extends t3lib_DB {
                                'database' => '', // Set by default (overridden)
                                'driver' => '', // ONLY "adodb" type; eg. "mysql"
                                'sequenceStart' => 1, // ONLY "adodb", first number in sequences/serials/...
-                               'useNameQuote' => 0 // ONLY "adodb", whether to use NameQuote() method from ADOdb to quote names
+                               'useNameQuote' => 0, // ONLY "adodb", whether to use NameQuote() method from ADOdb to quote names
+                               'quoteClob' => FALSE // ONLY "adodb", whether CLOB content field should be quoted before being sent to the DB
                        )
                ),
        );
@@ -987,13 +988,15 @@ class ux_t3lib_DB extends t3lib_DB {
 
                        $blobfields = array();
                        $nArr = array();
+                       $handlerKey = $this->handler_getFromTableList($table);
+                       $quoteClob = isset($this->handlerCfg[$handlerKey]['config']['quoteClob']) ? $this->handlerCfg[$handlerKey]['config']['quoteClob'] : FALSE;
                        foreach ($fields_values as $k => $v) {
                                if (!$this->runningNative() && $this->sql_field_metatype($table, $k) == 'B') {
                                        // we skip the field in the regular INSERT statement, it is only in blobfields
                                        $blobfields[$this->quoteFieldNames($k)] = $v;
                                } elseif (!$this->runningNative() && $this->sql_field_metatype($table, $k) == 'XL') {
                                        // we skip the field in the regular INSERT statement, it is only in clobfields
-                                       $clobfields[$this->quoteFieldNames($k)] = $v;
+                                       $clobfields[$this->quoteFieldNames($k)] = ($quoteClob ? $this->quoteStr($v, $table) : $v);
                                } else {
                                        // Add slashes old-school:
                                        // cast numerical values
@@ -1097,13 +1100,15 @@ class ux_t3lib_DB extends t3lib_DB {
                                }
 
                                $nArr = array();
+                               $handlerKey = $this->handler_getFromTableList($table);
+                               $quoteClob = isset($this->handlerCfg[$handlerKey]['config']['quoteClob']) ? $this->handlerCfg[$handlerKey]['config']['quoteClob'] : FALSE;
                                foreach ($fields_values as $k => $v) {
                                        if (!$this->runningNative() && $this->sql_field_metatype($table, $k) == 'B') {
                                                // we skip the field in the regular UPDATE statement, it is only in blobfields
                                                $blobfields[$this->quoteFieldNames($k)] = $v;
                                        } elseif (!$this->runningNative() && $this->sql_field_metatype($table, $k) == 'XL') {
                                                // we skip the field in the regular UPDATE statement, it is only in clobfields
-                                               $clobfields[$this->quoteFieldNames($k)] = $v;
+                                               $clobfields[$this->quoteFieldNames($k)] = ($quoteClob ? $this->quoteStr($v, $table) : $v);
                                        } else {
                                                // Add slashes old-school:
                                                // cast numeric values
index 88a4ce9..eb20bbd 100644 (file)
@@ -17,6 +17,7 @@ $TYPO3_CONF_VARS['EXTCONF']['dbal']['handlerCfg'] = array(
                'config' => array(
                        'driver' => 'mssql',
                        'useNameQuote' => FALSE,
+                       'quoteClob' => FALSE,
                ),
        ),
 );