Browse Source

Merge branch '2.6' into 3.0-merge

Conflicts:
	lib/Cake/Cache/Cache.php
	lib/Cake/Console/Command/Task/FixtureTask.php
	lib/Cake/Console/Command/Task/ViewTask.php
	lib/Cake/Console/ConsoleErrorHandler.php
	lib/Cake/Console/Shell.php
	lib/Cake/Core/App.php
	lib/Cake/Core/CakePlugin.php
	lib/Cake/Error/ExceptionRenderer.php
	lib/Cake/Model/Datasource/Database/Mysql.php
	lib/Cake/Model/Datasource/DboSource.php
	lib/Cake/Routing/Router.php
	lib/Cake/Test/Case/Controller/ScaffoldTest.php
	lib/Cake/Utility/ObjectCollection.php
	lib/Cake/Utility/Set.php
	lib/Cake/View/Errors/scaffold_error.ctp
	lib/Cake/View/Helper/CacheHelper.php
	lib/Cake/View/Helper/FormHelper.php
	lib/Cake/View/Helper/JsBaseEngineHelper.php
	lib/Cake/View/Helper/MootoolsEngineHelper.php
	tests/TestCase/Controller/Component/RequestHandlerComponentTest.php
ADmad 11 years ago
parent
commit
0358cf2b28

+ 4 - 1
src/Controller/Component/RequestHandlerComponent.php

@@ -407,7 +407,10 @@ class RequestHandlerComponent extends Component {
  *   in the request content type will be returned.
  */
 	public function requestedWith($type = null) {
-		if (!$this->request->is('post') && !$this->request->is('put')) {
+		if (!$this->request->is('post') &&
+			!$this->request->is('put') &&
+			!$this->request->is('delete')
+		) {
 			return null;
 		}
 		if (is_array($type)) {

+ 10 - 6
src/Network/Response.php

@@ -517,14 +517,18 @@ class Response {
  * @param string $name the header name
  * @param string $value the header value
  * @return void
+ * @throws \Cake\Error\Exception When headers have already been sent
  */
 	protected function _sendHeader($name, $value = null) {
-		if (!headers_sent()) {
-			if ($value === null) {
-				header($name);
-			} else {
-				header("{$name}: {$value}");
-			}
+		if (headers_sent($filename, $linenum)) {
+			throw new Error\Exception(
+				sprintf('Headers already sent in %d on line %s', $linenum, $filename)
+			);
+		}
+		if ($value === null) {
+			header($name);
+		} else {
+			header("{$name}: {$value}");
 		}
 	}
 

+ 4 - 2
src/Validation/Validation.php

@@ -274,7 +274,9 @@ class Validation {
 
 /**
  * Date validation, determines if the string passed is a valid date.
- * keys that expect full month, day and year will validate leap years
+ * keys that expect full month, day and year will validate leap years.
+ *
+ * Years are valid from 1800 to 2999.
  *
  * ### Formats:
  *
@@ -303,7 +305,7 @@ class Validation {
 		}
 		$month = '(0[123456789]|10|11|12)';
 		$separator = '([- /.])';
-		$fourDigitYear = '(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))';
+		$fourDigitYear = '(([1][8-9][0-9][0-9])|([2][0-9][0-9][0-9]))';
 		$twoDigitYear = '([0-9]{2})';
 		$year = '(?:' . $fourDigitYear . '|' . $twoDigitYear . ')';
 

+ 1 - 1
src/View/Helper/HtmlHelper.php

@@ -450,7 +450,7 @@ class HtmlHelper extends Helper {
  *
  * Add the script file to a custom block:
  *
- * `$this->Html->script('styles.js', null, array('block' => 'bodyScript'));`
+ * `$this->Html->script('styles.js', array('block' => 'bodyScript'));`
  *
  * ### Options
  *

+ 3 - 0
tests/TestCase/Controller/Component/RequestHandlerComponentTest.php

@@ -623,6 +623,9 @@ class RequestHandlerComponentTest extends TestCase {
 		$result = $this->RequestHandler->requestedWith(array('rss', 'atom'));
 		$this->assertFalse($result);
 
+		$this->RequestHandler->request->env('REQUEST_METHOD', 'DELETE');
+		$this->assertEquals('json', $this->RequestHandler->requestedWith());
+
 		$this->RequestHandler->request->env('REQUEST_METHOD', 'POST');
 		$this->RequestHandler->request->env('CONTENT_TYPE', '');
 		$this->RequestHandler->request->env('HTTP_CONTENT_TYPE', 'application/json');

+ 2 - 1
tests/TestCase/Validation/ValidationTest.php

@@ -1474,10 +1474,11 @@ class ValidationTest extends TestCase {
 		$this->assertTrue(Validation::date('2008', array('y')));
 		$this->assertTrue(Validation::date('2013', array('y')));
 		$this->assertTrue(Validation::date('2104', array('y')));
+		$this->assertTrue(Validation::date('1899', array('y')));
 		$this->assertFalse(Validation::date('20009', array('y')));
 		$this->assertFalse(Validation::date(' 2012', array('y')));
 		$this->assertFalse(Validation::date('3000', array('y')));
-		$this->assertFalse(Validation::date('1899', array('y')));
+		$this->assertFalse(Validation::date('1799', array('y')));
 	}
 
 /**