Fixed null MySQL handler that made some unit tests fail
authorXavier Perseguers <typo3@perseguers.ch>
Sun, 23 May 2010 10:03:43 +0000 (10:03 +0000)
committerXavier Perseguers <typo3@perseguers.ch>
Sun, 23 May 2010 10:03:43 +0000 (10:03 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dbal/trunk@33389 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/dbal/class.ux_t3lib_db.php

index abd0a67..5f332a6 100644 (file)
@@ -1427,7 +1427,12 @@ class ux_t3lib_DB extends t3lib_DB {
                $this->lastHandlerKey = $this->handler_getFromTableList($table);
                switch ((string)$this->handlerCfg[$this->lastHandlerKey]['type']) {
                        case 'native':
-                               $str = mysql_real_escape_string($str, $this->handlerInstance[$this->lastHandlerKey]['link']);
+                               if ($this->handlerInstance[$this->lastHandlerKey]['link']) {
+                                       $str = mysql_real_escape_string($str, $this->handlerInstance[$this->lastHandlerKey]['link']);
+                               } else {
+                                               // link may be null when unit testing DBAL
+                                       $str = str_replace('\'', '\\\'', $str);
+                               }
                                break;
                        case 'adodb':
                                $str = substr($this->handlerInstance[$this->lastHandlerKey]->qstr($str), 1, -1);