Browse Source

Merge branch 'master' into 2.3

Conflicts:
	lib/Cake/bootstrap.php
ADmad 13 years ago
parent
commit
1763f46340

+ 0 - 7
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.
  *

+ 1 - 1
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));
 				}

+ 1 - 1
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') {

+ 46 - 0
lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php

@@ -927,6 +927,52 @@ class MysqlTest extends CakeTestCase {
 	}
 
 /**
+ * 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
  */

+ 27 - 1
lib/Cake/Test/Case/Model/ModelWriteTest.php

@@ -4726,6 +4726,32 @@ class ModelWriteTest extends BaseModelTest {
 	}
 
 /**
+ * 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
  *
  * @link http://cakephp.lighthouseapp.com/projects/42648/tickets/277-test-saveall-with-validation-returns-incorrect-boolean-when-saving-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);
 	}
 

+ 2 - 0
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(''), '');
 	}
 

+ 2 - 1
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',

+ 6 - 4
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);
+	}
+}