Merge branch '2.7' into 2.8

This commit is contained in:
mark_story 2016-01-19 21:15:08 -05:00
commit 91109c33b2
3 changed files with 41 additions and 3 deletions

View file

@ -30,6 +30,13 @@ App::uses('File', 'Utility');
*/
class Shell extends Object {
/**
* Default error code
*
* @var int
*/
const CODE_ERROR = 1;
/**
* Output constant making verbose shells.
*
@ -580,7 +587,8 @@ class Shell extends Object {
$result = $this->stdin->read();
if ($result === false) {
return $this->_stop(1);
$this->_stop(self::CODE_ERROR);
return self::CODE_ERROR;
}
$result = trim($result);
@ -726,7 +734,8 @@ class Shell extends Object {
if (!empty($message)) {
$this->err($message);
}
return $this->_stop(1);
$this->_stop(self::CODE_ERROR);
return self::CODE_ERROR;
}
/**
@ -764,7 +773,8 @@ class Shell extends Object {
if (strtolower($key) === 'q') {
$this->out(__d('cake_console', '<error>Quitting</error>.'), 2);
return $this->_stop();
$this->_stop();
return true;
} elseif (strtolower($key) !== 'y') {
$this->out(__d('cake_console', 'Skip `%s`', $path), 2);
return false;

View file

@ -173,9 +173,13 @@ class CakeRequest implements ArrayAccess {
if (ini_get('magic_quotes_gpc') === '1') {
$this->data = stripslashes_deep($this->data);
}
$override = null;
if (env('HTTP_X_HTTP_METHOD_OVERRIDE')) {
$this->data['_method'] = env('HTTP_X_HTTP_METHOD_OVERRIDE');
$override = $this->data['_method'];
}
$isArray = is_array($this->data);
if ($isArray && isset($this->data['_method'])) {
if (!empty($_SERVER)) {
@ -183,8 +187,14 @@ class CakeRequest implements ArrayAccess {
} else {
$_ENV['REQUEST_METHOD'] = $this->data['_method'];
}
$override = $this->data['_method'];
unset($this->data['_method']);
}
if ($override && !in_array($override, array('POST', 'PUT', 'PATCH', 'DELETE'))) {
$this->data = array();
}
if ($isArray && isset($this->data['data'])) {
$data = $this->data['data'];
if (count($this->data) <= 1) {

View file

@ -2444,6 +2444,24 @@ XML;
$request->allowMethod('POST');
}
/**
* Tests that overriding the method to GET will clean all request
* data, to better simulate a GET request.
*
* @return void
*/
public function testMethodOverrideEmptyData() {
$_POST = array('_method' => 'GET', 'foo' => 'bar');
$_SERVER['REQUEST_METHOD'] = 'PUT';
$request = new CakeRequest('/posts/edit/1');
$this->assertEmpty($request->data);
$_POST = array('foo' => 'bar');
$_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'GET';
$request = new CakeRequest('/posts/edit/1');
$this->assertEmpty($request->data);
}
/**
* loadEnvironment method
*