diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 9343d349d..8cb9ac7bf 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -24,13 +24,6 @@ App::uses('CakePlugin', 'Core'); App::uses('L10n', 'I18n'); App::uses('Multibyte', 'I18n'); -if (function_exists('mb_internal_encoding')) { - $encoding = Configure::read('App.encoding'); - if (!empty($encoding)) { - mb_internal_encoding($encoding); - } -} - /** * I18n handles translation of Text and time format strings. * diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index b301f1c95..a28ca7ecf 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -2997,7 +2997,7 @@ class DboSource extends DataSource { $tableParameters = array_merge($tableParameters, $this->buildTableParameters($col, $table)); } } - if (empty($indexes) && !empty($primary)) { + if (!isset($columns['indexes']['PRIMARY']) && !empty($primary)) { $col = array('PRIMARY' => array('column' => $primary, 'unique' => 1)); $indexes = array_merge($indexes, $this->buildIndex($col, $table)); } diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 9f9e63bac..183fe6115 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2028,7 +2028,7 @@ class Model extends Object implements CakeEventListener { * @link http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-saveassociated-array-data-null-array-options-array * @link http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-saveall-array-data-null-array-options-array */ - public function saveAll($data, $options = array()) { + public function saveAll($data = array(), $options = array()) { $options = array_merge(array('validate' => 'first'), $options); if (Hash::numeric(array_keys($data))) { if ($options['validate'] === 'only') { diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index a738a9528..bd981e303 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -926,6 +926,52 @@ class MysqlTest extends CakeTestCase { $this->assertContains('`user_id` int(11) NOT NULL,', $result); } +/** + * Test that the primary flag is handled correctly. + * + * @return void + */ + public function testCreateSchemaAutoPrimaryKey() { + $schema = new CakeSchema(); + $schema->tables = array( + 'no_indexes' => array( + 'id' => array('type' => 'integer', 'null' => false, 'key' => 'primary'), + 'data' => array('type' => 'integer', 'null' => false), + 'indexes' => array(), + ) + ); + $result = $this->Dbo->createSchema($schema, 'no_indexes'); + $this->assertContains('PRIMARY KEY (`id`)', $result); + $this->assertNotContains('UNIQUE KEY', $result); + + $schema->tables = array( + 'primary_index' => array( + 'id' => array('type' => 'integer', 'null' => false), + 'data' => array('type' => 'integer', 'null' => false), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1), + 'some_index' => array('column' => 'data', 'unique' => 1) + ), + ) + ); + $result = $this->Dbo->createSchema($schema, 'primary_index'); + $this->assertContains('PRIMARY KEY (`id`)', $result); + $this->assertContains('UNIQUE KEY `some_index` (`data`)', $result); + + $schema->tables = array( + 'primary_flag_has_index' => array( + 'id' => array('type' => 'integer', 'null' => false, 'key' => 'primary'), + 'data' => array('type' => 'integer', 'null' => false), + 'indexes' => array ( + 'some_index' => array('column' => 'data', 'unique' => 1) + ), + ) + ); + $result = $this->Dbo->createSchema($schema, 'primary_flag_has_index'); + $this->assertContains('PRIMARY KEY (`id`)', $result); + $this->assertContains('UNIQUE KEY `some_index` (`data`)', $result); + } + /** * Tests that listSources method sends the correct query and parses the result accordingly * @return void diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index d317f6ca9..7b4e5a07c 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -4725,6 +4725,32 @@ class ModelWriteTest extends BaseModelTest { $this->assertEquals($expected, $TestModel->Comment->validationErrors); } +/** + * test that saveAll still behaves like previous versions (does not necessarily need a first argument) + * + * @return void + */ + public function testSaveAllWithSet() { + $this->loadFixtures('Article', 'Tag', 'Comment', 'User', 'ArticlesTag'); + $data = array( + 'Article' => array( + 'user_id' => 1, + 'title' => 'Article Has and belongs to Many Tags' + ), + 'Tag' => array( + 'Tag' => array(1, 2) + ), + 'Comment' => array( + array( + 'comment' => 'Article comment', + 'user_id' => 1 + ))); + $Article = new Article(); + $Article->set($data); + $result = $Article->saveAll(); + $this->assertFalse(empty($result)); + } + /** * test that saveAll behaves like plain save() when supplied empty data * @@ -4740,7 +4766,7 @@ class ModelWriteTest extends BaseModelTest { $this->assertFalse(empty($result)); $model = new ProductUpdateAll(); - $result = $model->saveAll(array()); + $result = $model->saveAll(); $this->assertFalse($result); } diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index cd1989248..9e7d43add 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -109,6 +109,7 @@ class InflectorTest extends CakeTestCase { $this->assertEquals(Inflector::singularize('roofs'), 'roof'); $this->assertEquals(Inflector::singularize('foes'), 'foe'); $this->assertEquals(Inflector::singularize('databases'), 'database'); + $this->assertEquals(Inflector::singularize('cookies'), 'cookie'); $this->assertEquals(Inflector::singularize(''), ''); } @@ -160,6 +161,7 @@ class InflectorTest extends CakeTestCase { $this->assertEquals(Inflector::pluralize('cafe'), 'cafes'); $this->assertEquals(Inflector::pluralize('roof'), 'roofs'); $this->assertEquals(Inflector::pluralize('foe'), 'foes'); + $this->assertEquals(Inflector::pluralize('cookie'), 'cookies'); $this->assertEquals(Inflector::pluralize(''), ''); } diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index f18323e5a..738ace2f0 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -55,7 +55,7 @@ class Inflector { '/$/' => 's', ), 'uninflected' => array( - '.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'people' + '.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'people', 'cookie' ), 'irregular' => array( 'atlas' => 'atlases', @@ -63,6 +63,7 @@ class Inflector { 'brother' => 'brothers', 'cafe' => 'cafes', 'child' => 'children', + 'cookie' => 'cookies', 'corpus' => 'corpuses', 'cow' => 'cows', 'ganglion' => 'ganglions', diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index ceadb006e..6c5474d1b 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -129,14 +129,10 @@ if (!defined('JS_URL')) { define('JS_URL', 'js/'); } - - - require CAKE . 'basics.php'; require CAKE . 'Core' . DS . 'App.php'; require CAKE . 'Error' . DS . 'exceptions.php'; - /** * Full url prefix */ @@ -165,3 +161,9 @@ App::$bootstrapping = true; Configure::bootstrap(isset($boot) ? $boot : true); +if (function_exists('mb_internal_encoding')) { + $encoding = Configure::read('App.encoding'); + if (!empty($encoding)) { + mb_internal_encoding($encoding); + } +}