diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 9d7184165..09c48ae35 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -351,7 +351,7 @@ class DboSource extends DataSource { } $data = $this->startQuote . str_replace('.', $this->endQuote . '.' . $this->startQuote, $data) . $this->endQuote; $data = str_replace($this->startQuote . $this->startQuote, $this->startQuote, $data); - + if (!empty($this->endQuote) && $this->endQuote == $this->startQuote) { $oddMatches = substr_count($data, $this->endQuote); if ($oddMatches % 2 == 1) { @@ -1831,7 +1831,6 @@ class DboSource extends DataSource { $null = null; $this->rollback($null); } - $this->close(); parent::__destruct(); } /** diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index f72ba2446..28ad59eb7 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -247,7 +247,7 @@ class FormHelper extends AppHelper { if (isset($submit)) { $out .= $this->submit($submit, $submitOptions); - } elseif (isset($this->params['_Token']) && !empty($this->params['_Token']) && !empty($this->fields)) { + } elseif (isset($this->params['_Token']) && !empty($this->params['_Token'])) { $out .= $this->secure($this->fields); $this->fields = array(); } @@ -256,16 +256,20 @@ class FormHelper extends AppHelper { return $this->output($out); } function secure($fields) { - $append = '
'; - foreach ($fields as $key => $value) { - if(strpos($key, '_') !== 0) { - sort($fields[$key]); + if (!empty($fields)) { + $append = '
'; + + foreach ($fields as $key => $value) { + if(strpos($key, '_') !== 0) { + sort($fields[$key]); + } } + ksort($fields); + $append .= $this->hidden('_Token.fields', array('value' => urlencode(Security::hash(serialize($fields) . CAKE_SESSION_STRING)), 'id' => 'TokenFields' . mt_rand())); + $append .= '
'; + return $append; } - ksort($fields); - $append .= $this->hidden('_Token.fields', array('value' => urlencode(Security::hash(serialize($fields) . CAKE_SESSION_STRING)), 'id' => 'TokenFields' . mt_rand())); - $append .= ''; - return $append; + return null; } function __secure($model = null, $options = null) { if (!$model) { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php index 38fe59966..bc170d72f 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php @@ -109,20 +109,6 @@ class DboMssqlTest extends UnitTestCase { * @access public */ var $Db = null; -/** - * Skip if cannot connect to mysql - * - * @return void - * @access public - */ - function skip() { - $skip = true; - if(function_exists('mssql_connect')) { - $skip = false; - } - //$this->skipif ($skip, 'Mssql not installed'); - $this->skipif (false, 'Mssql not installed'); - } /** * Sets up a Dbo class instance for testing * @@ -130,7 +116,7 @@ class DboMssqlTest extends UnitTestCase { * @access public */ function setUp() { - require_once r('//', '/', APP) . 'config/database.php'; + require_once APP . 'config' . DS . 'database.php'; $config = new DATABASE_CONFIG(); $this->db =& new DboMssqlTestDb($config->default, false); $this->db->fullDebug = false; @@ -143,6 +129,7 @@ class DboMssqlTest extends UnitTestCase { * @return void * @access public */ + function testQuoting() { $result = $this->db->fields($this->model); $expected = array( @@ -175,16 +162,5 @@ class DboMssqlTest extends UnitTestCase { $result = $this->db->value('1,2', 'float'); $this->assertIdentical($expected, $result); } -/** - * Sets up a Dbo class instance for testing - * - * @return void - * @access public - */ - function tearDown() { - unset($this->model); - //unset($this->db); - } } - ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 646621925..edce350a8 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -119,9 +119,8 @@ class DboMysqlTest extends UnitTestCase { if(function_exists('mysql_connect')) { $skip = false; } - $this->skipif ($skip, 'Mysql not installed'); + $this->skipif ($skip, 'MySql not installed'); } - /** * Sets up a Dbo class instance for testing * @@ -129,9 +128,9 @@ class DboMysqlTest extends UnitTestCase { * @access public */ function setUp() { - require_once r('//', '/', APP) . 'config/database.php'; + require_once APP . 'config' . DS . 'database.php'; $config = new DATABASE_CONFIG(); - $this->Db =& new DboMysqlTestDb($config->default, false); + $this->Db =& new DboMysqlTestDb($config->default); $this->Db->fullDebug = false; $this->model = new MysqlTestModel(); } @@ -151,27 +150,27 @@ class DboMysqlTest extends UnitTestCase { * @access public */ function testQuoting() { - +$this->skipif ($this->Db->connected, 'Could not connect to database'); $result = $this->Db->fields($this->model); $expected = array( - 'MysqlTestModel`.`id` AS `MysqlTestModel__0`', - '`MysqlTestModel`.`client_id` AS `MysqlTestModel__1`', - '`MysqlTestModel`.`name` AS `MysqlTestModel__2`', - '`MysqlTestModel`.`login` AS `MysqlTestModel__3`', - '`MysqlTestModel`.`passwd` AS `MysqlTestModel__4`', - '`MysqlTestModel`.`addr_1` AS `MysqlTestModel__5`', - '`MysqlTestModel`.`addr_2` AS `MysqlTestModel__6`', - '`MysqlTestModel`.`zip_code` AS `MysqlTestModel__7`', - '`MysqlTestModel`.`city` AS `MysqlTestModel__8`', - '`MysqlTestModel`.`country` AS `MysqlTestModel__9`', - '`MysqlTestModel`.`phone` AS `MysqlTestModel__10`', - '`MysqlTestModel`.`fax` AS `MysqlTestModel__11`', - '`MysqlTestModel`.`url` AS `MysqlTestModel__12`', - '`MysqlTestModel`.`email` AS `MysqlTestModel__13`', - '`MysqlTestModel`.`comments` AS `MysqlTestModel__14`', - '`MysqlTestModel`.`last_login` AS `MysqlTestModel__15`', - '`MysqlTestModel`.`created` AS `MysqlTestModel__16`', - '`MysqlTestModel`.`updated` AS `MysqlTestModel__17`' + '`MysqlTestModel`.`id`', + '`MysqlTestModel`.`client_id`', + '`MysqlTestModel`.`name`', + '`MysqlTestModel`.`login`', + '`MysqlTestModel`.`passwd`', + '`MysqlTestModel`.`addr_1`', + '`MysqlTestModel`.`addr_2`', + '`MysqlTestModel`.`zip_code`', + '`MysqlTestModel`.`city`', + '`MysqlTestModel`.`country`', + '`MysqlTestModel`.`phone`', + '`MysqlTestModel`.`fax`', + '`MysqlTestModel`.`url`', + '`MysqlTestModel`.`email`', + '`MysqlTestModel`.`comments`', + '`MysqlTestModel`.`last_login`', + '`MysqlTestModel`.`created`', + '`MysqlTestModel`.`updated`' ); $this->assertEqual($result, $expected); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 4fd6b8aa7..f93c83b24 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -109,7 +109,7 @@ class DboPostgresTest extends UnitTestCase { */ var $Db = null; /** - * Skip if cannot connect to mysql + * Skip if cannot connect to postgres * * @return void * @access public @@ -119,7 +119,7 @@ class DboPostgresTest extends UnitTestCase { if(function_exists('pg_connect')) { $skip = false; } - $this->skipif (true, 'Postgres not installed'); + $this->skipif ($skip, 'Postgres not installed'); } /** @@ -129,7 +129,7 @@ class DboPostgresTest extends UnitTestCase { * @access public */ function setUp() { - require_once r('//', '/', APP) . 'config/database.php'; + require_once APP . 'config' . DS . 'database.php'; $config = new DATABASE_CONFIG(); $this->Db =& new DboPostgresTestDb($config->default, false); $this->Db->fullDebug = false; @@ -154,28 +154,28 @@ class DboPostgresTest extends UnitTestCase { $result = $this->Db->fields($this->model); $expected = array( - 'PostgresTestModel`.`id` AS `PostgresTestModel__0`', - '`PostgresTestModel`.`client_id` AS `PostgresTestModel__1`', - '`PostgresTestModel`.`name` AS `PostgresTestModel__2`', - '`PostgresTestModel`.`login` AS `PostgresTestModel__3`', - '`PostgresTestModel`.`passwd` AS `PostgresTestModel__4`', - '`PostgresTestModel`.`addr_1` AS `PostgresTestModel__5`', - '`PostgresTestModel`.`addr_2` AS `PostgresTestModel__6`', - '`PostgresTestModel`.`zip_code` AS `PostgresTestModel__7`', - '`PostgresTestModel`.`city` AS `PostgresTestModel__8`', - '`PostgresTestModel`.`country` AS `PostgresTestModel__9`', - '`PostgresTestModel`.`phone` AS `PostgresTestModel__10`', - '`PostgresTestModel`.`fax` AS `PostgresTestModel__11`', - '`PostgresTestModel`.`url` AS `PostgresTestModel__12`', - '`PostgresTestModel`.`email` AS `PostgresTestModel__13`', - '`PostgresTestModel`.`comments` AS `PostgresTestModel__14`', - '`PostgresTestModel`.`last_login` AS `PostgresTestModel__15`', - '`PostgresTestModel`.`created` AS `PostgresTestModel__16`', - '`PostgresTestModel`.`updated` AS `PostgresTestModel__17`' + '"PostgresTestModel"."id" AS "PostgresTestModel__id"', + '"PostgresTestModel"."client_id" AS "PostgresTestModel__client_id"', + '"PostgresTestModel"."name" AS "PostgresTestModel__name"', + '"PostgresTestModel"."login" AS "PostgresTestModel__login"', + '"PostgresTestModel"."passwd" AS "PostgresTestModel__passwd"', + '"PostgresTestModel"."addr_1" AS "PostgresTestModel__addr_1"', + '"PostgresTestModel"."addr_2" AS "PostgresTestModel__addr_2"', + '"PostgresTestModel"."zip_code" AS "PostgresTestModel__zip_code"', + '"PostgresTestModel"."city" AS "PostgresTestModel__city"', + '"PostgresTestModel"."country" AS "PostgresTestModel__country"', + '"PostgresTestModel"."phone" AS "PostgresTestModel__phone"', + '"PostgresTestModel"."fax" AS "PostgresTestModel__fax"', + '"PostgresTestModel"."url" AS "PostgresTestModel__url"', + '"PostgresTestModel"."email" AS "PostgresTestModel__email"', + '"PostgresTestModel"."comments" AS "PostgresTestModel__comments"', + '"PostgresTestModel"."last_login" AS "PostgresTestModel__last_login"', + '"PostgresTestModel"."created" AS "PostgresTestModel__created"', + '"PostgresTestModel"."updated" AS "PostgresTestModel__updated"' ); $this->assertEqual($result, $expected); - $expected = 1.2; + $expected = "'1.2'"; $result = $this->Db->value(1.2, 'float'); $this->assertIdentical($expected, $result);