diff --git a/.travis.yml b/.travis.yml
index 900901156..c3492d555 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -41,6 +41,8 @@ before_script:
- sh -c "if [ '$PHPCS' = '1' ]; then composer global require 'cakephp/cakephp-codesniffer:1.*'; fi"
- sh -c "if [ '$PHPCS' = '1' ]; then ~/.composer/vendor/bin/phpcs --config-set installed_paths ~/.composer/vendor/cakephp/cakephp-codesniffer; fi"
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
+ - if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.0" ]] ; then print "yes" | pecl install apcu-5.1.3; else print "yes" | pecl install apcu-4.0.11; fi
+ - echo -e "extension = apcu.so\napc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- phpenv rehash
- set +H
- echo "getMessage();
if (method_exists($connectionError, 'getAttributes')):
$attributes = $connectionError->getAttributes();
- if (isset($errorMsg['message'])):
+ if (isset($attributes['message'])):
$errorMsg .= '
' . $attributes['message'];
endif;
endif;
@@ -209,8 +209,10 @@ You can also add some CSS styles for your pages at: %s.',
-
-
+ CakePHP Official Forum
+
+
+
irc.freenode.net #cakephp
diff --git a/app/composer.json b/app/composer.json
new file mode 100644
index 000000000..e05128e72
--- /dev/null
+++ b/app/composer.json
@@ -0,0 +1,37 @@
+{
+ "name": "cakephp/app",
+ "description": "CakePHP Application skeleton",
+ "type": "library",
+ "keywords": ["application", "cakephp"],
+ "homepage": "http://cakephp.org",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "CakePHP Community",
+ "homepage": "https://github.com/cakephp/cakephp/graphs/contributors"
+ }
+ ],
+ "support": {
+ "issues": "https://github.com/cakephp/cakephp/issues",
+ "forum": "http://stackoverflow.com/tags/cakephp",
+ "irc": "irc://irc.freenode.org/cakephp",
+ "source": "https://github.com/cakephp/cakephp"
+ },
+ "require": {
+ "php": ">=5.3.0",
+ "ext-mcrypt": "*"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "3.7.*",
+ "cakephp/cakephp": "~2.8"
+ },
+ "suggest": {
+ "cakephp/cakephp-codesniffer": "Easily check code formatting against the CakePHP coding standards."
+ },
+ "bin": [
+ "lib/Cake/Console/cake"
+ ],
+ "config": {
+ "vendor-dir": "Vendor/"
+ }
+}
diff --git a/build.xml b/build.xml
index 786916b99..98c48bae9 100644
--- a/build.xml
+++ b/build.xml
@@ -213,10 +213,10 @@
-->
-
+
-
+
diff --git a/composer.json b/composer.json
index 5c2ac6692..3f3ead208 100644
--- a/composer.json
+++ b/composer.json
@@ -23,9 +23,11 @@
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
- "cakephp/debug_kit" : "^2.2.0",
"cakephp/cakephp-codesniffer": "^1.0.0"
},
+ "config": {
+ "vendor-dir": "vendors/"
+ },
"bin": [
"lib/Cake/Console/cake"
]
diff --git a/lib/Cake/Cache/Engine/ApcEngine.php b/lib/Cake/Cache/Engine/ApcEngine.php
index da31651e3..8500560df 100644
--- a/lib/Cake/Cache/Engine/ApcEngine.php
+++ b/lib/Cake/Cache/Engine/ApcEngine.php
@@ -31,6 +31,13 @@ class ApcEngine extends CacheEngine {
*/
protected $_compiledGroupNames = array();
+/**
+ * APC or APCu extension
+ *
+ * @var string
+ */
+ protected $_apcExtension = 'apc';
+
/**
* Initialize the Cache Engine
*
@@ -47,6 +54,10 @@ class ApcEngine extends CacheEngine {
}
$settings += array('engine' => 'Apc');
parent::init($settings);
+ if (function_exists('apcu_dec')) {
+ $this->_apcExtension = 'apcu';
+ return true;
+ }
return function_exists('apc_dec');
}
@@ -63,8 +74,9 @@ class ApcEngine extends CacheEngine {
if ($duration) {
$expires = time() + $duration;
}
- apc_store($key . '_expires', $expires, $duration);
- return apc_store($key, $value, $duration);
+ $func = $this->_apcExtension . '_store';
+ $func($key . '_expires', $expires, $duration);
+ return $func($key, $value, $duration);
}
/**
@@ -75,11 +87,12 @@ class ApcEngine extends CacheEngine {
*/
public function read($key) {
$time = time();
- $cachetime = (int)apc_fetch($key . '_expires');
+ $func = $this->_apcExtension . '_fetch';
+ $cachetime = (int)$func($key . '_expires');
if ($cachetime !== 0 && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) {
return false;
}
- return apc_fetch($key);
+ return $func($key);
}
/**
@@ -90,7 +103,8 @@ class ApcEngine extends CacheEngine {
* @return New incremented value, false otherwise
*/
public function increment($key, $offset = 1) {
- return apc_inc($key, $offset);
+ $func = $this->_apcExtension . '_inc';
+ return $func($key, $offset);
}
/**
@@ -101,7 +115,8 @@ class ApcEngine extends CacheEngine {
* @return New decremented value, false otherwise
*/
public function decrement($key, $offset = 1) {
- return apc_dec($key, $offset);
+ $func = $this->_apcExtension . '_dec';
+ return $func($key, $offset);
}
/**
@@ -111,7 +126,8 @@ class ApcEngine extends CacheEngine {
* @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed
*/
public function delete($key) {
- return apc_delete($key);
+ $func = $this->_apcExtension . '_delete';
+ return $func($key);
}
/**
@@ -125,19 +141,20 @@ class ApcEngine extends CacheEngine {
if ($check) {
return true;
}
+ $func = $this->_apcExtension . '_delete';
if (class_exists('APCIterator', false)) {
$iterator = new APCIterator(
'user',
'/^' . preg_quote($this->settings['prefix'], '/') . '/',
APC_ITER_NONE
);
- apc_delete($iterator);
+ $func($iterator);
return true;
}
- $cache = apc_cache_info('user');
+ $cache = $this->_apcExtension === 'apc' ? apc_cache_info('user') : apcu_cache_info();
foreach ($cache['cache_list'] as $key) {
if (strpos($key['info'], $this->settings['prefix']) === 0) {
- apc_delete($key['info']);
+ $func($key['info']);
}
}
return true;
@@ -157,11 +174,13 @@ class ApcEngine extends CacheEngine {
}
}
- $groups = apc_fetch($this->_compiledGroupNames);
+ $fetchFunc = $this->_apcExtension . '_fetch';
+ $storeFunc = $this->_apcExtension . '_store';
+ $groups = $fetchFunc($this->_compiledGroupNames);
if (count($groups) !== count($this->settings['groups'])) {
foreach ($this->_compiledGroupNames as $group) {
if (!isset($groups[$group])) {
- apc_store($group, 1);
+ $storeFunc($group, 1);
$groups[$group] = 1;
}
}
@@ -184,7 +203,8 @@ class ApcEngine extends CacheEngine {
* @return bool success
*/
public function clearGroup($group) {
- apc_inc($this->settings['prefix'] . $group, 1, $success);
+ $func = $this->_apcExtension . '_inc';
+ $func($this->settings['prefix'] . $group, 1, $success);
return $success;
}
@@ -203,7 +223,8 @@ class ApcEngine extends CacheEngine {
if ($duration) {
$expires = time() + $duration;
}
- apc_add($key . '_expires', $expires, $duration);
- return apc_add($key, $value, $duration);
+ $func = $this->_apcExtension . '_add';
+ $func($key . '_expires', $expires, $duration);
+ return $func($key, $value, $duration);
}
}
diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php
index fc2d91343..f9f8f70ed 100644
--- a/lib/Cake/Console/Command/Task/ControllerTask.php
+++ b/lib/Cake/Console/Command/Task/ControllerTask.php
@@ -182,11 +182,11 @@ class ControllerTask extends BakeTask {
$components = $this->doComponents();
$wannaUseSession = $this->in(
- __d('cake_console', "Would you like to use Session flash messages?"), array('y', 'n'), 'y'
+ __d('cake_console', "Would you like to use the FlashComponent to display flash messages?"), array('y', 'n'), 'y'
);
if (strtolower($wannaUseSession) === 'y') {
- array_push($components, 'Session');
+ array_push($components, 'Session', 'Flash');
}
array_unique($components);
}
@@ -384,9 +384,9 @@ class ControllerTask extends BakeTask {
* @return array Components the user wants to use.
*/
public function doComponents() {
- $components = array('Paginator', 'Flash');
+ $components = array('Paginator');
return array_merge($components, $this->_doPropertyChoices(
- __d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent and FlashComponent?"),
+ __d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent?"),
__d('cake_console', "Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'")
));
}
diff --git a/lib/Cake/Console/Templates/skel/View/Pages/home.ctp b/lib/Cake/Console/Templates/skel/View/Pages/home.ctp
index ad84a2553..6484c83d9 100644
--- a/lib/Cake/Console/Templates/skel/View/Pages/home.ctp
+++ b/lib/Cake/Console/Templates/skel/View/Pages/home.ctp
@@ -214,6 +214,8 @@ You can also add some CSS styles for your pages at: %s.',
+
+
irc.freenode.net #cakephp
diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php
index ea1d72704..9c3bc56a2 100644
--- a/lib/Cake/Controller/Component/RequestHandlerComponent.php
+++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php
@@ -505,7 +505,12 @@ 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') && !$this->request->is('delete')) {
+ if (
+ !$this->request->is('patch') &&
+ !$this->request->is('post') &&
+ !$this->request->is('put') &&
+ !$this->request->is('delete')
+ ) {
return null;
}
if (is_array($type)) {
diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php
index 9bdc81c4c..7dd81f8a4 100644
--- a/lib/Cake/Model/Datasource/Database/Sqlite.php
+++ b/lib/Cake/Model/Datasource/Database/Sqlite.php
@@ -185,6 +185,9 @@ class Sqlite extends DboSource {
'default' => $default,
'length' => $this->length($column['type'])
);
+ if (in_array($fields[$column['name']]['type'], array('timestamp', 'datetime')) && strtoupper($fields[$column['name']]['default']) === 'CURRENT_TIMESTAMP') {
+ $fields[$column['name']]['default'] = null;
+ }
if ($column['pk'] == 1) {
$fields[$column['name']]['key'] = $this->index['PRI'];
$fields[$column['name']]['null'] = false;
diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php
index 14be37c4b..dfb59157c 100644
--- a/lib/Cake/Model/Datasource/DboSource.php
+++ b/lib/Cake/Model/Datasource/DboSource.php
@@ -2302,6 +2302,7 @@ class DboSource extends DataSource {
$this->_transactionNesting = 0;
if ($this->fullDebug) {
+ $this->took = $this->numRows = $this->affected = false;
$this->logQuery('BEGIN');
}
return $this->_transactionStarted = $this->_connection->beginTransaction();
@@ -2315,6 +2316,7 @@ class DboSource extends DataSource {
protected function _beginNested() {
$query = 'SAVEPOINT LEVEL' . ++$this->_transactionNesting;
if ($this->fullDebug) {
+ $this->took = $this->numRows = $this->affected = false;
$this->logQuery($query);
}
$this->_connection->exec($query);
@@ -2335,6 +2337,7 @@ class DboSource extends DataSource {
if ($this->_transactionNesting === 0) {
if ($this->fullDebug) {
+ $this->took = $this->numRows = $this->affected = false;
$this->logQuery('COMMIT');
}
$this->_transactionStarted = false;
@@ -2357,6 +2360,7 @@ class DboSource extends DataSource {
protected function _commitNested() {
$query = 'RELEASE SAVEPOINT LEVEL' . $this->_transactionNesting--;
if ($this->fullDebug) {
+ $this->took = $this->numRows = $this->affected = false;
$this->logQuery($query);
}
$this->_connection->exec($query);
@@ -2377,6 +2381,7 @@ class DboSource extends DataSource {
if ($this->_transactionNesting === 0) {
if ($this->fullDebug) {
+ $this->took = $this->numRows = $this->affected = false;
$this->logQuery('ROLLBACK');
}
$this->_transactionStarted = false;
@@ -2399,6 +2404,7 @@ class DboSource extends DataSource {
protected function _rollbackNested() {
$query = 'ROLLBACK TO SAVEPOINT LEVEL' . $this->_transactionNesting--;
if ($this->fullDebug) {
+ $this->took = $this->numRows = $this->affected = false;
$this->logQuery($query);
}
$this->_connection->exec($query);
@@ -3190,10 +3196,13 @@ class DboSource extends DataSource {
$statement->bindValue($i, $val, $columnMap[$col]);
$i += 1;
}
+ $t = microtime(true);
$statement->execute();
$statement->closeCursor();
if ($this->fullDebug) {
+ $this->took = round((microtime(true) - $t) * 1000, 0);
+ $this->numRows = $this->affected = $statement->rowCount();
$this->logQuery($sql, $value);
}
}
diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php
index 8bd2b3c50..db97a04ea 100644
--- a/lib/Cake/Network/CakeRequest.php
+++ b/lib/Cake/Network/CakeRequest.php
@@ -97,6 +97,7 @@ class CakeRequest implements ArrayAccess {
*/
protected $_detectors = array(
'get' => array('env' => 'REQUEST_METHOD', 'value' => 'GET'),
+ 'patch' => array('env' => 'REQUEST_METHOD', 'value' => 'PATCH'),
'post' => array('env' => 'REQUEST_METHOD', 'value' => 'POST'),
'put' => array('env' => 'REQUEST_METHOD', 'value' => 'PUT'),
'delete' => array('env' => 'REQUEST_METHOD', 'value' => 'DELETE'),
@@ -1124,6 +1125,9 @@ class CakeRequest implements ArrayAccess {
* @return bool
*/
public function offsetExists($name) {
+ if ($name === 'url' || $name === 'data') {
+ return true;
+ }
return isset($this->params[$name]);
}
diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php
index bf62be85a..33e37ca68 100644
--- a/lib/Cake/Network/Email/CakeEmail.php
+++ b/lib/Cake/Network/Email/CakeEmail.php
@@ -1203,7 +1203,7 @@ class CakeEmail {
* @throws SocketException
*/
public static function deliver($to = null, $subject = null, $message = null, $transportConfig = 'fast', $send = true) {
- $class = __CLASS__;
+ $class = get_called_class();
/** @var CakeEmail $instance */
$instance = new $class($transportConfig);
if ($to !== null) {
diff --git a/lib/Cake/Network/Email/DebugTransport.php b/lib/Cake/Network/Email/DebugTransport.php
index 5f6ae298d..8ab64e1b0 100644
--- a/lib/Cake/Network/Email/DebugTransport.php
+++ b/lib/Cake/Network/Email/DebugTransport.php
@@ -15,6 +15,7 @@
* @since CakePHP(tm) v 2.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
+App::uses('AbstractTransport', 'Network/Email');
/**
* Debug Transport class, useful for emulate the email sending process and inspect the resulted
diff --git a/lib/Cake/Network/Email/MailTransport.php b/lib/Cake/Network/Email/MailTransport.php
index 9e27899d3..3b40f21c1 100644
--- a/lib/Cake/Network/Email/MailTransport.php
+++ b/lib/Cake/Network/Email/MailTransport.php
@@ -15,6 +15,7 @@
* @since CakePHP(tm) v 2.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
+App::uses('AbstractTransport', 'Network/Email');
/**
* Send mail using mail() function
diff --git a/lib/Cake/Network/Email/SmtpTransport.php b/lib/Cake/Network/Email/SmtpTransport.php
index 64d0090b5..c581c9a2f 100644
--- a/lib/Cake/Network/Email/SmtpTransport.php
+++ b/lib/Cake/Network/Email/SmtpTransport.php
@@ -15,7 +15,7 @@
* @since CakePHP(tm) v 2.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
-
+App::uses('AbstractTransport', 'Network/Email');
App::uses('CakeSocket', 'Network');
/**
diff --git a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php
index 171e9d551..6ae6d643a 100644
--- a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php
+++ b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php
@@ -25,6 +25,13 @@ App::uses('Cache', 'Cache');
*/
class ApcEngineTest extends CakeTestCase {
+/**
+ * APC extension to be used
+ *
+ * @var string
+ */
+ protected $_apcExtension = 'apc';
+
/**
* setUp method
*
@@ -32,12 +39,17 @@ class ApcEngineTest extends CakeTestCase {
*/
public function setUp() {
parent::setUp();
- $this->skipIf(!function_exists('apc_store'), 'Apc is not installed or configured properly.');
+ $hasApc = extension_loaded('apc') || extension_loaded('apcu');
+ $this->skipIf(!$hasApc, 'Apc is not installed or configured properly.');
if (PHP_SAPI === 'cli') {
$this->skipIf(!ini_get('apc.enable_cli'), 'APC is not enabled for the CLI.');
}
+ if (extension_loaded('apcu')) {
+ $this->_apcExtension = 'apcu';
+ }
+
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('apc', array('engine' => 'Apc', 'prefix' => 'cake_'));
@@ -147,7 +159,8 @@ class ApcEngineTest extends CakeTestCase {
* @return void
*/
public function testDecrement() {
- $this->skipIf(!function_exists('apc_dec'), 'No apc_dec() function, cannot test decrement().');
+ $hasSupport = function_exists('apc_dec') || function_exists('apcu_dec');
+ $this->skipIf(!$hasSupport, 'No apc_dec()/apcu_dec() function, cannot test decrement().');
$result = Cache::write('test_decrement', 5, 'apc');
$this->assertTrue($result);
@@ -171,7 +184,8 @@ class ApcEngineTest extends CakeTestCase {
* @return void
*/
public function testIncrement() {
- $this->skipIf(!function_exists('apc_inc'), 'No apc_inc() function, cannot test increment().');
+ $hasSupport = function_exists('apc_inc') || function_exists('apcu_inc');
+ $this->skipIf(!function_exists('apc_inc'), 'No apc_inc()/apcu_inc() function, cannot test increment().');
$result = Cache::write('test_increment', 5, 'apc');
$this->assertTrue($result);
@@ -195,14 +209,18 @@ class ApcEngineTest extends CakeTestCase {
* @return void
*/
public function testClear() {
- apc_store('not_cake', 'survive');
+ $storeFunc = $this->_apcExtension . '_store';
+ $fetchFunc = $this->_apcExtension . '_fetch';
+ $deleteFunc = $this->_apcExtension . '_delete';
+
+ $storeFunc('not_cake', 'survive');
Cache::write('some_value', 'value', 'apc');
$result = Cache::clear(false, 'apc');
$this->assertTrue($result);
$this->assertFalse(Cache::read('some_value', 'apc'));
- $this->assertEquals('survive', apc_fetch('not_cake'));
- apc_delete('not_cake');
+ $this->assertEquals('survive', $fetchFunc('not_cake'));
+ $deleteFunc('not_cake');
}
/**
@@ -213,6 +231,7 @@ class ApcEngineTest extends CakeTestCase {
* @return void
*/
public function testGroupsReadWrite() {
+ $incFunc = $this->_apcExtension . '_inc';
Cache::config('apc_groups', array(
'engine' => 'Apc',
'duration' => 0,
@@ -222,12 +241,12 @@ class ApcEngineTest extends CakeTestCase {
$this->assertTrue(Cache::write('test_groups', 'value', 'apc_groups'));
$this->assertEquals('value', Cache::read('test_groups', 'apc_groups'));
- apc_inc('test_group_a');
+ $incFunc('test_group_a');
$this->assertFalse(Cache::read('test_groups', 'apc_groups'));
$this->assertTrue(Cache::write('test_groups', 'value2', 'apc_groups'));
$this->assertEquals('value2', Cache::read('test_groups', 'apc_groups'));
- apc_inc('test_group_b');
+ $incFunc('test_group_b');
$this->assertFalse(Cache::read('test_groups', 'apc_groups'));
$this->assertTrue(Cache::write('test_groups', 'value3', 'apc_groups'));
$this->assertEquals('value3', Cache::read('test_groups', 'apc_groups'));
diff --git a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php
index 9d8c9e2b2..ded7e9596 100644
--- a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php
+++ b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php
@@ -222,7 +222,7 @@ class ControllerTaskTest extends CakeTestCase {
public function testDoComponentsNo() {
$this->Task->expects($this->any())->method('in')->will($this->returnValue('n'));
$result = $this->Task->doComponents();
- $this->assertSame(array('Paginator', 'Flash'), $result);
+ $this->assertSame(array('Paginator'), $result);
}
/**
@@ -235,7 +235,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security '));
$result = $this->Task->doComponents();
- $expected = array('Paginator', 'Flash', 'RequestHandler', 'Security');
+ $expected = array('Paginator', 'RequestHandler', 'Security');
$this->assertEquals($expected, $result);
}
@@ -249,7 +249,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security, , '));
$result = $this->Task->doComponents();
- $expected = array('Paginator', 'Flash', 'RequestHandler', 'Security');
+ $expected = array('Paginator', 'RequestHandler', 'Security');
$this->assertEquals($expected, $result);
}
diff --git a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php
index 1e9f8daaf..028729fae 100644
--- a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php
+++ b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php
@@ -618,6 +618,9 @@ class RequestHandlerComponentTest extends CakeTestCase {
$_SERVER['REQUEST_METHOD'] = 'DELETE';
$this->assertEquals('json', $this->RequestHandler->requestedWith());
+ $_SERVER['REQUEST_METHOD'] = 'PATCH';
+ $this->assertEquals('json', $this->RequestHandler->requestedWith());
+
$_SERVER['REQUEST_METHOD'] = 'POST';
unset($_SERVER['CONTENT_TYPE']);
$_SERVER['HTTP_CONTENT_TYPE'] = 'application/json';
diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php
index 14758c7d7..46950760f 100644
--- a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php
+++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php
@@ -168,7 +168,13 @@ class SqliteTest extends CakeTestCase {
$dbName = 'db' . rand() . '$(*%&).db';
$this->assertFalse(file_exists(TMP . $dbName));
- $db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName)));
+ try {
+ $db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName)));
+ } catch (MissingConnectionException $e) {
+ // This might be caused by NTFS file systems, where '*' is a forbidden character. Repeat without this character.
+ $dbName = str_replace('*', '', $dbName);
+ $db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName)));
+ }
$this->assertTrue(file_exists(TMP . $dbName));
$db->execute("CREATE TABLE test_list (id VARCHAR(255));");
@@ -422,6 +428,40 @@ class SqliteTest extends CakeTestCase {
$this->Dbo->query('DROP TABLE ' . $tableName);
}
+/**
+ * Test that describe ignores `default current_timestamp` in timestamp columns.
+ *
+ * @return void
+ */
+ public function testDescribeHandleCurrentTimestamp() {
+ $name = $this->Dbo->fullTableName('timestamp_default_values');
+ $sql = <<Dbo->execute($sql);
+ $model = new Model(array(
+ 'table' => 'timestamp_default_values',
+ 'ds' => 'test',
+ 'alias' => 'TimestampDefaultValue'
+ ));
+ $result = $this->Dbo->describe($model);
+ $this->Dbo->execute('DROP TABLE ' . $name);
+
+ $this->assertNull($result['limit_date']['default']);
+
+ $schema = new CakeSchema(array(
+ 'connection' => 'test',
+ 'testdescribes' => $result
+ ));
+ $result = $this->Dbo->createSchema($schema);
+ $this->assertContains('"limit_date" timestamp NOT NULL', $result);
+ }
+
/**
* Test virtualFields with functions.
*
@@ -466,6 +506,7 @@ class SqliteTest extends CakeTestCase {
* @return void
*/
public function testNestedTransaction() {
+ $this->Dbo->useNestedTransactions = true;
$this->skipIf($this->Dbo->nestedTransactionSupported() === false, 'The Sqlite version do not support nested transaction');
$this->loadFixtures('User');
diff --git a/lib/Cake/Test/Case/Network/CakeSocketTest.php b/lib/Cake/Test/Case/Network/CakeSocketTest.php
index e93882d06..c678d9c5b 100644
--- a/lib/Cake/Test/Case/Network/CakeSocketTest.php
+++ b/lib/Cake/Test/Case/Network/CakeSocketTest.php
@@ -318,11 +318,6 @@ class CakeSocketTest extends CakeTestCase {
* @return void
*/
public function testEnableCrypto() {
- // testing on ssl server
- $this->_connectSocketToSslTls();
- $this->assertTrue($this->Socket->enableCrypto('sslv3', 'client'));
- $this->Socket->disconnect();
-
// testing on tls server
$this->_connectSocketToSslTls();
$this->assertTrue($this->Socket->enableCrypto('tls', 'client'));
diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php
index 552922818..1d53713ae 100644
--- a/lib/Cake/Test/Case/Utility/FolderTest.php
+++ b/lib/Cake/Test/Case/Utility/FolderTest.php
@@ -1227,4 +1227,85 @@ class FolderTest extends CakeTestCase {
$Folder->delete();
}
+/**
+ * testSortByTime method
+ *
+ * Verify that the order using modified time is correct.
+ *
+ * @return void
+ */
+ public function testSortByTime() {
+ $Folder = new Folder(TMP . 'test_sort_by_time', true);
+
+ $file2 = new File($Folder->pwd() . DS . 'file_2.tmp');
+ $file2->create();
+
+ sleep(1);
+
+ $file1 = new File($Folder->pwd() . DS . 'file_1.tmp');
+ $file1->create();
+
+ $expected = array('file_2.tmp', 'file_1.tmp');
+ $result = $Folder->find('.*', Folder::SORT_TIME);
+ $this->assertSame($expected, $result);
+
+ $Folder->delete();
+ }
+
+/**
+ * testSortByTime2 method
+ *
+ * Verify that the sort order using modified time is correct.
+ *
+ * @return void
+ */
+ public function testSortByTime2() {
+ $Folder = new Folder(TMP . 'test_sort_by_time2', true);
+
+ $fileC = new File($Folder->pwd() . DS . 'c.txt');
+ $fileC->create();
+
+ sleep(1);
+
+ $fileA = new File($Folder->pwd() . DS . 'a.txt');
+ $fileA->create();
+
+ sleep(1);
+
+ $fileB = new File($Folder->pwd() . DS . 'b.txt');
+ $fileB->create();
+
+ $expected = array('c.txt', 'a.txt', 'b.txt');
+ $result = $Folder->find('.*', Folder::SORT_TIME);
+ $this->assertSame($expected, $result);
+
+ $Folder->delete();
+ }
+
+/**
+ * Verify that the sort order using name is correct.
+ *
+ * @return void
+ */
+ public function testSortByName() {
+ $Folder = new Folder(TMP . 'test_sort_by_name', true);
+
+ $fileA = new File($Folder->pwd() . DS . 'a.txt');
+ $fileA->create();
+
+ $fileC = new File($Folder->pwd() . DS . 'c.txt');
+ $fileC->create();
+
+ sleep(1);
+
+ $fileB = new File($Folder->pwd() . DS . 'b.txt');
+ $fileB->create();
+
+ $expected = array('a.txt', 'b.txt', 'c.txt');
+ $result = $Folder->find('.*', Folder::SORT_NAME);
+ $this->assertSame($expected, $result);
+
+ $Folder->delete();
+ }
+
}
diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php
index 749678ed1..bf20c7fdd 100644
--- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php
+++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -1599,6 +1599,28 @@ class FormHelperTest extends CakeTestCase {
$this->assertEquals(array(), $this->Form->fields);
}
+/**
+ * test reset unlockFields, when create new form.
+ *
+ * @return void
+ */
+ public function testResetUnlockFields() {
+ $this->Form->request['_Token'] = array(
+ 'key' => 'testKey',
+ 'unlockedFields' => array()
+ );
+
+ $this->Form->unlockField('Contact.id');
+ $this->Form->create('Contact');
+ $this->Form->hidden('Contact.id', array('value' => 1));
+ $this->assertEmpty($this->Form->fields, 'Field should be unlocked');
+ $this->Form->end();
+
+ $this->Form->create('Contact');
+ $this->Form->hidden('Contact.id', array('value' => 1));
+ $this->assertEquals(1, $this->Form->fields['Contact.id'], 'Hidden input should be secured.');
+ }
+
/**
* testTagIsInvalid method
*
@@ -3940,6 +3962,25 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
+ $result = $this->Form->radio('Model.field', array('option A', 'option B'), array('fieldset' => 'classy-stuff'));
+ $expected = array(
+ 'fieldset' => array('class' => 'classy-stuff'),
+ 'legend' => array(),
+ 'Field',
+ '/legend',
+ 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '', 'id' => 'ModelField_'),
+ array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField0')),
+ array('label' => array('for' => 'ModelField0')),
+ 'option A',
+ '/label',
+ array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField1')),
+ array('label' => array('for' => 'ModelField1')),
+ 'option B',
+ '/label',
+ '/fieldset'
+ );
+ $this->assertTags($result, $expected);
+
$result = $this->Form->radio(
'Employee.gender',
array('male' => 'Male', 'female' => 'Female'),
diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php
index e23f70e5a..1b59ba155 100644
--- a/lib/Cake/Utility/Folder.php
+++ b/lib/Cake/Utility/Folder.php
@@ -46,6 +46,16 @@ class Folder {
*/
const SKIP = 'skip';
+/**
+ * Sort mode by name
+ */
+ const SORT_NAME = 'name';
+
+/**
+ * Sort mode by time
+ */
+ const SORT_TIME = 'time';
+
/**
* Path to Folder.
*
@@ -71,6 +81,14 @@ class Folder {
*/
public $mode = 0755;
+/**
+ * Functions array to be called depending on the sort type chosen.
+ */
+ protected $_fsorts = array(
+ self::SORT_NAME => 'getPathname',
+ self::SORT_TIME => 'getCTime'
+ );
+
/**
* Holds messages from last method.
*
@@ -155,14 +173,14 @@ class Folder {
* Returns an array of the contents of the current directory.
* The returned array holds two arrays: One of directories and one of files.
*
- * @param bool $sort Whether you want the results sorted, set this and the sort property
+ * @param string|bool $sort Whether you want the results sorted, set this and the sort property
* to false to get unsorted results.
* @param array|bool $exceptions Either an array or boolean true will not grab dot files
* @param bool $fullPath True returns the full path
* @return mixed Contents of current directory as an array, an empty array on failure
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::read
*/
- public function read($sort = true, $exceptions = false, $fullPath = false) {
+ public function read($sort = self::SORT_NAME, $exceptions = false, $fullPath = false) {
$dirs = $files = array();
if (!$this->pwd()) {
@@ -178,6 +196,11 @@ class Folder {
} catch (Exception $e) {
return array($dirs, $files);
}
+ if (!is_bool($sort) && isset($this->_fsorts[$sort])) {
+ $methodName = $this->_fsorts[$sort];
+ } else {
+ $methodName = $this->_fsorts[self::SORT_NAME];
+ }
foreach ($iterator as $item) {
if ($item->isDot()) {
@@ -191,14 +214,22 @@ class Folder {
$name = $item->getPathName();
}
if ($item->isDir()) {
- $dirs[] = $name;
+ $dirs[$item->{$methodName}()][] = $name;
} else {
- $files[] = $name;
+ $files[$item->{$methodName}()][] = $name;
}
}
+
if ($sort || $this->sort) {
- sort($dirs);
- sort($files);
+ ksort($dirs);
+ ksort($files);
+ }
+
+ if ($dirs) {
+ $dirs = call_user_func_array('array_merge', $dirs);
+ }
+ if ($files) {
+ $files = call_user_func_array('array_merge', $files);
}
return array($dirs, $files);
}
diff --git a/lib/Cake/Utility/Security.php b/lib/Cake/Utility/Security.php
index 01ade1ef9..be128e64a 100644
--- a/lib/Cake/Utility/Security.php
+++ b/lib/Cake/Utility/Security.php
@@ -191,8 +191,10 @@ class Security {
E_USER_WARNING
);
$bytes = '';
- while ($bytes < $length) {
+ $byteLength = 0;
+ while ($byteLength < $length) {
$bytes .= static::hash(CakeText::uuid() . uniqid(mt_rand(), true), 'sha512', true);
+ $byteLength = strlen($bytes);
}
return substr($bytes, 0, $length);
}
diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt
index fa6a5f109..9a3a91b5c 100644
--- a/lib/Cake/VERSION.txt
+++ b/lib/Cake/VERSION.txt
@@ -17,4 +17,4 @@
// @license http://www.opensource.org/licenses/mit-license.php MIT License
// +--------------------------------------------------------------------------------------------+ //
////////////////////////////////////////////////////////////////////////////////////////////////////
-2.8.3
+2.8.5
diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php
index e283930ff..fd8eab62c 100644
--- a/lib/Cake/View/Helper/FormHelper.php
+++ b/lib/Cake/View/Helper/FormHelper.php
@@ -560,6 +560,7 @@ class FormHelper extends AppHelper {
$this->setEntity(null);
$out .= $this->Html->useTag('formend');
+ $this->_unlockedFields = array();
$this->_View->modelScope = false;
$this->requestType = null;
return $out;
@@ -932,9 +933,12 @@ class FormHelper extends AppHelper {
if (isset($options['legend'])) {
$legend = $options['legend'];
+ unset($options['legend']);
}
+
if (isset($options['fieldset'])) {
$fieldset = $options['fieldset'];
+ unset($options['fieldset']);
}
if (empty($fields)) {
@@ -972,7 +976,7 @@ class FormHelper extends AppHelper {
}
if (is_string($fieldset)) {
- $fieldsetClass = sprintf(' class="%s"', $fieldset);
+ $fieldsetClass = array('class' => $fieldset);
} else {
$fieldsetClass = '';
}
@@ -1512,6 +1516,7 @@ class FormHelper extends AppHelper {
* - `between` - the string between legend and input set or array of strings to insert
* strings between each input block
* - `legend` - control whether or not the widget set has a fieldset & legend
+ * - `fieldset` - sets the class of the fieldset. Fieldset is only generated if legend attribute is provided
* - `value` - indicate a value that is should be checked
* - `label` - boolean to indicate whether or not labels for widgets show be displayed
* - `hiddenField` - boolean to indicate if you want the results of radio() to include
@@ -1546,6 +1551,12 @@ class FormHelper extends AppHelper {
$legend = __(Inflector::humanize($this->field()));
}
+ $fieldsetAttrs = '';
+ if (isset($attributes['fieldset'])) {
+ $fieldsetAttrs = array('class' => $attributes['fieldset']);
+ unset($attributes['fieldset']);
+ }
+
$label = true;
if (isset($attributes['label'])) {
$label = $attributes['label'];
@@ -1639,8 +1650,10 @@ class FormHelper extends AppHelper {
if (is_array($between)) {
$between = '';
}
+
if ($legend) {
- $out = $this->Html->useTag('fieldset', '', $this->Html->useTag('legend', $legend) . $between . $out);
+ $out = $this->Html->useTag('legend', $legend) . $between . $out;
+ $out = $this->Html->useTag('fieldset', $fieldsetAttrs, $out);
}
return $out;
}