Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into 2.3

Conflicts:
	lib/Cake/bootstrap.php
  • Loading branch information...
commit 1763f463406a52fe3d3a09b1bc4fb0fd6f23b005 2 parents d75bd48 + 922d986
ADmad ADmad authored
7 lib/Cake/I18n/I18n.php
View
@@ -24,13 +24,6 @@
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.
*
2  lib/Cake/Model/Datasource/DboSource.php
View
@@ -2997,7 +2997,7 @@ public function createSchema($schema, $tableName = null) {
$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));
}
2  lib/Cake/Model/Model.php
View
@@ -2028,7 +2028,7 @@ protected function _prepareUpdateFields($data) {
* @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 lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
View
@@ -927,6 +927,52 @@ public function testTwoColumnsWithPrimaryKey() {
}
/**
+ * 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
*/
28 lib/Cake/Test/Case/Model/ModelWriteTest.php
View
@@ -4726,6 +4726,32 @@ public function testSaveAllHasManyValidationOnly() {
}
/**
+ * 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 @@ public function testSaveAllEmptyData() {
$this->assertFalse(empty($result));
$model = new ProductUpdateAll();
- $result = $model->saveAll(array());
+ $result = $model->saveAll();
$this->assertFalse($result);
}
2  lib/Cake/Test/Case/Utility/InflectorTest.php
View
@@ -109,6 +109,7 @@ public function testInflectingSingulars() {
$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 @@ public function testInflectingPlurals() {
$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(''), '');
}
3  lib/Cake/Utility/Inflector.php
View
@@ -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',
10 lib/Cake/bootstrap.php
View
@@ -129,14 +129,10 @@
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 @@
Configure::bootstrap(isset($boot) ? $boot : true);
+if (function_exists('mb_internal_encoding')) {
+ $encoding = Configure::read('App.encoding');
+ if (!empty($encoding)) {
+ mb_internal_encoding($encoding);
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.