Browse Source

Merge branch '1.3' into merger

Conflicts:
	cake/console/libs/bake.php
	cake/libs/configure.php
	cake/libs/controller/components/request_handler.php
	cake/tests/cases/console/libs/tasks/fixture.test.php
	cake/tests/cases/libs/controller/components/request_handler.test.php
	lib/Cake/Cache/Engine/FileEngine.php
	lib/Cake/Test/Case/Controller/ScaffoldTest.php
	lib/Cake/Utility/Validation.php
Mark Story 14 years ago
parent
commit
59c6b419e5

+ 2 - 0
lib/Cake/Console/Command/BakeShell.php

@@ -65,6 +65,8 @@ class BakeShell extends Shell {
  * @return mixed
  */
 	public function main() {
+		Configure::write('Cache.disable', 1);
+
 		if (!is_dir($this->DbConfig->path)) {
 			$path = $this->Project->execute();
 			if (!empty($path)) {

+ 11 - 0
lib/Cake/Console/Command/Task/BakeTask.php

@@ -44,6 +44,17 @@ class BakeTask extends Shell {
 	public $interactive = false;
 
 /**
+ * Disable caching for baking.
+ * This forces the most current database schema to be used.
+ *
+ * @return void
+ */
+	function startup() {
+		Configure::write('Cache.disable', 1);
+		parent::startup();
+	}
+
+/**
  * Gets the path for output.  Checks the plugin property
  * and returns the correct path.
  *

+ 9 - 13
lib/Cake/Console/Command/Task/FixtureTask.php

@@ -316,35 +316,30 @@ class FixtureTask extends BakeTask {
 								 $insert = substr($insert, 0, (int)$fieldInfo['length'] - 2);
 							}
 						}
-						$insert = "'$insert'";
 					break;
 					case 'timestamp':
-						$ts = time();
-						$insert = "'$ts'";
+						$insert = time();
 					break;
 					case 'datetime':
-						$ts = date('Y-m-d H:i:s');
-						$insert = "'$ts'";
+						$insert = date('Y-m-d H:i:s');
 					break;
 					case 'date':
-						$ts = date('Y-m-d');
-						$insert = "'$ts'";
+						$insert = date('Y-m-d');
 					break;
 					case 'time':
-						$ts = date('H:i:s');
-						$insert = "'$ts'";
+						$insert = date('H:i:s');
 					break;
 					case 'boolean':
 						$insert = 1;
 					break;
 					case 'text':
-						$insert = "'Lorem ipsum dolor sit amet, aliquet feugiat.";
+						$insert = "Lorem ipsum dolor sit amet, aliquet feugiat.";
 						$insert .= " Convallis morbi fringilla gravida,";
 						$insert .= " phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin";
 						$insert .= " venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla";
 						$insert .= " vestibulum massa neque ut et, id hendrerit sit,";
 						$insert .= " feugiat in taciti enim proin nibh, tempor dignissim, rhoncus";
-						$insert .= " duis vestibulum nunc mattis convallis.'";
+						$insert .= " duis vestibulum nunc mattis convallis.";
 					break;
 				}
 				$record[$field] = $insert;
@@ -365,7 +360,8 @@ class FixtureTask extends BakeTask {
 		foreach ($records as $record) {
 			$values = array();
 			foreach ($record as $field => $value) {
-				$values[] = "\t\t\t'$field' => $value";
+				$val = var_export($value, true);
+				$values[] = "\t\t\t'$field' => $val";
 			}
 			$out .= "\t\tarray(\n";
 			$out .= implode(",\n", $values);
@@ -408,7 +404,7 @@ class FixtureTask extends BakeTask {
 		foreach ($records as $record) {
 			$row = array();
 			foreach ($record[$modelObject->alias] as $field => $value) {
-				$row[$field] = $db->value($value, $schema[$field]['type']);
+				$row[$field] = $value;
 			}
 			$out[] = $row;
 		}

+ 4 - 0
lib/Cake/I18n/L10n.php

@@ -93,6 +93,7 @@ class L10n {
 								/* Arabic */ 'ara' => 'ar',
 								/* Armenian - Armenia */ 'hye' => 'hy',
 								/* Basque */ 'baq' => 'eu',
+								/* Tibetan */ 'bod' => 'bo',
 								/* Bosnian */ 'bos' => 'bs',
 								/* Bulgarian */ 'bul' => 'bg',
 								/* Byelorussian */ 'bel' => 'be',
@@ -194,6 +195,9 @@ class L10n {
 										'ar-ye' => array('language' => 'Arabic (Yemen)', 'locale' => 'ar_ye', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'),
 										'be' => array('language' => 'Byelorussian', 'locale' => 'bel', 'localeFallback' => 'bel', 'charset' => 'utf-8', 'direction' => 'ltr'),
 										'bg' => array('language' => 'Bulgarian', 'locale' => 'bul', 'localeFallback' => 'bul', 'charset' => 'utf-8', 'direction' => 'ltr'),
+										'bo' => array('language' => 'Tibetan', 'locale' => 'bod', 'localeFallback' => 'bod', 'charset' => 'utf-8', 'direction' => 'ltr'),
+										'bo-cn' => array('language' => 'Tibetan (China)', 'locale' => 'bo_cn', 'localeFallback' => 'bod', 'charset' => 'utf-8', 'direction' => 'ltr'),
+										'bo-in' => array('language' => 'Tibetan (India)', 'locale' => 'bo_in', 'localeFallback' => 'bod', 'charset' => 'utf-8', 'direction' => 'ltr'),
 										'bs' => array('language' => 'Bosnian', 'locale' => 'bos', 'localeFallback' => 'bos', 'charset' => 'utf-8', 'direction' => 'ltr'),
 										'ca' => array('language' => 'Catalan', 'locale' => 'cat', 'localeFallback' => 'cat', 'charset' => 'utf-8', 'direction' => 'ltr'),
 										'cs' => array('language' => 'Czech', 'locale' => 'cze', 'localeFallback' => 'cze', 'charset' => 'utf-8', 'direction' => 'ltr'),

+ 25 - 0
lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php

@@ -165,6 +165,31 @@ class FixtureTaskTest extends CakeTestCase {
 	}
 
 /**
+ * Ensure that fixture data doesn't get overly escaped.
+ *
+ * @return void
+ */
+	function testImportRecordsNoEscaping() {
+		$Article = ClassRegistry::init('Article');
+		$Article->updateAll(array('body' => "'Body \"value\"'"));
+
+		$this->Task->interactive = true;
+		$this->Task->expects($this->at(0))
+			->method('in')
+			->will($this->returnValue('WHERE 1=1 LIMIT 10'));
+
+		$this->Task->connection = 'test';
+		$this->Task->path = '/my/path/';
+		$result = $this->Task->bake('Article', false, array(
+			'fromTable' => true, 
+			'schema' => 'Article',
+			'records' => false
+		));
+
+		$this->assertRegExp("/'body' => 'Body \"value\"'/", $result, 'Data has bad escaping');
+	}
+
+/**
  * test that execute passes runs bake depending with named model.
  *
  * @return void

+ 4 - 0
lib/Cake/Test/Case/Utility/InflectorTest.php

@@ -106,6 +106,8 @@ class InflectorTest extends CakeTestCase {
 		$this->assertEqual(Inflector::singularize('bases'), 'basis');
 		$this->assertEqual(Inflector::singularize('analyses'), 'analysis');
 		$this->assertEqual(Inflector::singularize('curves'), 'curve');
+		$this->assertEqual(Inflector::singularize('cafes'), 'cafe');
+		$this->assertEqual(Inflector::singularize('roofs'), 'roof');
 
 		$this->assertEqual(Inflector::singularize(''), '');
 	}
@@ -153,6 +155,8 @@ class InflectorTest extends CakeTestCase {
 		$this->assertEqual(Inflector::pluralize('tax'), 'taxes');
 		$this->assertEqual(Inflector::pluralize('wave'), 'waves');
 		$this->assertEqual(Inflector::pluralize('bureau'), 'bureaus');
+		$this->assertEqual(Inflector::pluralize('cafe'), 'cafes');
+		$this->assertEqual(Inflector::pluralize('roof'), 'roofs');
 		$this->assertEqual(Inflector::pluralize(''), '');
 	}
 

+ 1 - 0
lib/Cake/Test/Case/Utility/ValidationTest.php

@@ -1366,6 +1366,7 @@ class ValidationTest extends CakeTestCase {
 		$this->assertTrue(Validation::date('Dec 27 2006', array('Mdy')));
 		$this->assertFalse(Validation::date('27 Dec 2006', array('Mdy')));
 		$this->assertFalse(Validation::date('2006 December 27', array('Mdy')));
+		$this->assertTrue(Validation::date('Sep 12, 2011', array('Mdy')));
 	}
 
 /**

+ 1 - 0
lib/Cake/Utility/Inflector.php

@@ -67,6 +67,7 @@ class Inflector {
 			'atlas' => 'atlases',
 			'beef' => 'beefs',
 			'brother' => 'brothers',
+			'cafe' => 'cafes',
 			'child' => 'children',
 			'corpus' => 'corpuses',
 			'cow' => 'cows',

+ 1 - 1
lib/Cake/Utility/Validation.php

@@ -300,7 +300,7 @@ class Validation {
 		$regex['mdy'] = '%^(?:(?:(?:0?[13578]|1[02])(\\/|-|\\.|\\x20)31)\\1|(?:(?:0?[13-9]|1[0-2])(\\/|-|\\.|\\x20)(?:29|30)\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:0?2(\\/|-|\\.|\\x20)29\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\\/|-|\\.|\\x20)(?:0?[1-9]|1\\d|2[0-8])\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$%';
 		$regex['ymd'] = '%^(?:(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.|\\x20)(?:0?2\\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.|\\x20)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]))))$%';
 		$regex['dMy'] = '/^((31(?!\\ (Feb(ruary)?|Apr(il)?|June?|(Sep(?=\\b|t)t?|Nov)(ember)?)))|((30|29)(?!\\ Feb(ruary)?))|(29(?=\\ Feb(ruary)?\\ (((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\\d|2[0-8])\\ (Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)\\ ((1[6-9]|[2-9]\\d)\\d{2})$/';
-		$regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(ember)?)\\ (0?[1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\ ((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/';
+		$regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep)(tember)?|(Nov|Dec)(ember)?)\\ (0?[1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\ ((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/';
 		$regex['My'] = '%^(Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)[ /]((1[6-9]|[2-9]\\d)\\d{2})$%';
 		$regex['my'] = '%^(((0[123456789]|10|11|12)([- /.])(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))))$%';