From cd07850337bc6830ec7e9ac86fbb4b5d2c407f17 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Just Date: Sat, 30 Apr 2016 13:11:34 -0400 Subject: [PATCH 01/53] Merge branch 'backport-8741-8690' into 2.x --- lib/Cake/Cache/Engine/FileEngine.php | 2 +- lib/Cake/Test/Case/Utility/ValidationTest.php | 6 ++++++ lib/Cake/Utility/Validation.php | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Cache/Engine/FileEngine.php b/lib/Cake/Cache/Engine/FileEngine.php index d650e60ee6c..155d1950ce1 100644 --- a/lib/Cake/Cache/Engine/FileEngine.php +++ b/lib/Cake/Cache/Engine/FileEngine.php @@ -132,7 +132,7 @@ public function write($key, $data, $duration) { } $expires = time() + $duration; - $contents = $expires . $lineBreak . $data . $lineBreak; + $contents = implode([$expires, $lineBreak, $data, $lineBreak]); if ($this->settings['lock']) { $this->_File->flock(LOCK_EX); diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index e3f7f25cd75..aa4d7c30244 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -403,6 +403,12 @@ public function testCc() { $this->assertTrue(Validation::cc('5467639122779531', array('mc'))); $this->assertTrue(Validation::cc('5297350261550024', array('mc'))); $this->assertTrue(Validation::cc('5162739131368058', array('mc'))); + //Mastercard (additional 2016 BIN) + $this->assertTrue(Validation::cc('2221000000000009', array('mc'))); + $this->assertTrue(Validation::cc('2720999999999996', array('mc'))); + $this->assertTrue(Validation::cc('2223000010005798', array('mc'))); + $this->assertTrue(Validation::cc('2623430710235708', array('mc'))); + $this->assertTrue(Validation::cc('2420452519835723', array('mc'))); //Solo 16 $this->assertTrue(Validation::cc('6767432107064987', array('solo'))); $this->assertTrue(Validation::cc('6334667758225411', array('solo'))); diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 48bf8714772..12338846311 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -182,7 +182,7 @@ public static function cc($check, $type = 'fast', $deep = false, $regex = null) 'enroute' => '/^2(?:014|149)\\d{11}$/', 'jcb' => '/^(3\\d{4}|2100|1800)\\d{11}$/', 'maestro' => '/^(?:5020|6\\d{3})\\d{12}$/', - 'mc' => '/^5[1-5]\\d{14}$/', + 'mc' => '/^(5[1-5]\\d{14})|(2(?:22[1-9]|2[3-9][0-9]|[3-6][0-9]{2}|7[0-1][0-9]|720)\\d{12})$/', 'solo' => '/^(6334[5-9][0-9]|6767[0-9]{2})\\d{10}(\\d{2,3})?$/', 'switch' => '/^(?:49(03(0[2-9]|3[5-9])|11(0[1-2]|7[4-9]|8[1-2])|36[0-9]{2})\\d{10}(\\d{2,3})?)|(?:564182\\d{10}(\\d{2,3})?)|(6(3(33[0-4][0-9])|759[0-9]{2})\\d{10}(\\d{2,3})?)$/', From c2f028ab49fd02c2a2e482ce665a1c811fd42a19 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Just Date: Sat, 30 Apr 2016 13:13:14 -0400 Subject: [PATCH 02/53] Fix spacing --- lib/Cake/Test/Case/Utility/ValidationTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index aa4d7c30244..9b34c03b107 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -403,12 +403,12 @@ public function testCc() { $this->assertTrue(Validation::cc('5467639122779531', array('mc'))); $this->assertTrue(Validation::cc('5297350261550024', array('mc'))); $this->assertTrue(Validation::cc('5162739131368058', array('mc'))); - //Mastercard (additional 2016 BIN) - $this->assertTrue(Validation::cc('2221000000000009', array('mc'))); - $this->assertTrue(Validation::cc('2720999999999996', array('mc'))); - $this->assertTrue(Validation::cc('2223000010005798', array('mc'))); - $this->assertTrue(Validation::cc('2623430710235708', array('mc'))); - $this->assertTrue(Validation::cc('2420452519835723', array('mc'))); + //Mastercard (additional 2016 BIN) + $this->assertTrue(Validation::cc('2221000000000009', array('mc'))); + $this->assertTrue(Validation::cc('2720999999999996', array('mc'))); + $this->assertTrue(Validation::cc('2223000010005798', array('mc'))); + $this->assertTrue(Validation::cc('2623430710235708', array('mc'))); + $this->assertTrue(Validation::cc('2420452519835723', array('mc'))); //Solo 16 $this->assertTrue(Validation::cc('6767432107064987', array('solo'))); $this->assertTrue(Validation::cc('6334667758225411', array('solo'))); From ab79ab9c5533cd71c2e562503c7328d5bfa2d23e Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 30 Apr 2016 14:14:45 -0400 Subject: [PATCH 03/53] Fix short-array usage. --- lib/Cake/Cache/Engine/FileEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Cache/Engine/FileEngine.php b/lib/Cake/Cache/Engine/FileEngine.php index 155d1950ce1..5bbbd937e87 100644 --- a/lib/Cake/Cache/Engine/FileEngine.php +++ b/lib/Cake/Cache/Engine/FileEngine.php @@ -132,7 +132,7 @@ public function write($key, $data, $duration) { } $expires = time() + $duration; - $contents = implode([$expires, $lineBreak, $data, $lineBreak]); + $contents = implode(array($expires, $lineBreak, $data, $lineBreak)); if ($this->settings['lock']) { $this->_File->flock(LOCK_EX); From ade9d8a8115e26e968cf89d0821881c4b6a84572 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 1 May 2016 22:21:23 -0400 Subject: [PATCH 04/53] Restore backwards compatibility with old 2.x in FormHelper. Restore the behavior of the string 'action' option to its former glory. While we've deprecated this it needs to continue working as it did before. Refs #8628 --- .../Test/Case/View/Helper/FormHelperTest.php | 31 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 3 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 2ca6217122c..08ee366a9e1 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -8699,6 +8699,37 @@ public function testCreateNoUrl() { $this->assertTags($result, $expected); } +/** + * Test that the action key still uses the model as the implicit controller + * when the url option is undefined. While the action parameter is deprecated + * we need it to continue working for the duration of 2.x + * + * @return void + */ + public function testCreateUrlImpliedController() + { + $restore = error_reporting(E_ALL ^ E_USER_DEPRECATED); + $this->Form->request['controller'] = 'posts'; + $result = $this->Form->create('Comment', array( + 'action' => 'addComment', + 'id' => 'addCommentForm', + 'type' => 'POST' + )); + $expected = array( + 'form' => array( + 'action' => '/comments/addComment', + 'id' => 'addCommentForm', + 'method' => 'post', + 'accept-charset' => strtolower(Configure::read('App.encoding')) + ), + 'div' => array('style' => 'display:none;'), + 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'), + '/div' + ); + $this->assertTags($result, $expected); + error_reporting($restore); + } + /** * Test the onsubmit option for create() * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 5d583a9c440..5cad0468891 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -382,6 +382,7 @@ public function create($model = null, $options = array()) { if (isset($options['action'])) { trigger_error('Using key `action` is deprecated, use `url` directly instead.', E_USER_DEPRECATED); } + if (is_array($options['url']) && isset($options['url']['action'])) { $options['action'] = $options['url']['action']; } @@ -393,7 +394,7 @@ public function create($model = null, $options = array()) { if ($options['action'] === null && $options['url'] === null) { $options['action'] = $this->request->here(false); - } elseif (is_array($options['url'])) { + } elseif (empty($options['url']) || is_array($options['url'])) { if (empty($options['url']['controller'])) { if (!empty($model)) { $options['url']['controller'] = Inflector::underscore(Inflector::pluralize($model)); From 32cb25465f5710c97a92d653b1e3df75b7ed3eba Mon Sep 17 00:00:00 2001 From: Mark Sch Date: Mon, 2 May 2016 10:42:42 +0200 Subject: [PATCH 05/53] Make CS tests pass. --- lib/Cake/Test/Case/View/Helper/FormHelperTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 08ee366a9e1..c2627b8d3db 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -8706,8 +8706,7 @@ public function testCreateNoUrl() { * * @return void */ - public function testCreateUrlImpliedController() - { + public function testCreateUrlImpliedController() { $restore = error_reporting(E_ALL ^ E_USER_DEPRECATED); $this->Form->request['controller'] = 'posts'; $result = $this->Form->create('Comment', array( From 31cddbe48adbbe4d4315e4cd82ea52927a84a2b5 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 2 May 2016 14:37:47 -0700 Subject: [PATCH 06/53] Only add Flash component when required If a user selected no to the question "Would you like to use Session flash messages?" it would still use the Flash component, but not use it --- lib/Cake/Console/Command/Task/ControllerTask.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index fc2d9134348..f9f8f70ed49 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -182,11 +182,11 @@ protected function _interactive() { $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 @@ public function doHelpers() { * @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'") )); } From 8cd5a64c27abf47e02aba29403428f8e4937de45 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 2 May 2016 22:18:41 -0400 Subject: [PATCH 07/53] Update version number to 2.8.4 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index fa6a5f1094c..5922b09f5ac 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.4 From bce571736c5e169672bdcbf0428adf30ae853745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Teixeira?= Date: Tue, 3 May 2016 09:11:30 -0300 Subject: [PATCH 08/53] Including forum link --- app/View/Pages/home.ctp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/View/Pages/home.ctp b/app/View/Pages/home.ctp index 67078a984b6..f5c2ea226a7 100644 --- a/app/View/Pages/home.ctp +++ b/app/View/Pages/home.ctp @@ -209,6 +209,8 @@ You can also add some CSS styles for your pages at: %s.',
  • +
  • CakePHP Official Forum +
    • CakePHP discussion forum
  • irc.freenode.net #cakephp From d640e6874a06793733da1eaab22fe4376035e394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Tue, 3 May 2016 14:19:25 +0200 Subject: [PATCH 09/53] Add new forum link to home page --- app/View/Pages/home.ctp | 2 ++ lib/Cake/Console/Templates/skel/View/Pages/home.ctp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/View/Pages/home.ctp b/app/View/Pages/home.ctp index 67078a984b6..066da415618 100644 --- a/app/View/Pages/home.ctp +++ b/app/View/Pages/home.ctp @@ -211,6 +211,8 @@ You can also add some CSS styles for your pages at: %s.',
  • +
  • +
  • irc.freenode.net #cakephp
  • diff --git a/lib/Cake/Console/Templates/skel/View/Pages/home.ctp b/lib/Cake/Console/Templates/skel/View/Pages/home.ctp index ad84a25539e..6484c83d937 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
  • From 695005dcfaa40fb64bae31d8a55a3058f4532ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Teixeira?= Date: Tue, 3 May 2016 09:32:01 -0300 Subject: [PATCH 10/53] Fixing indentation --- app/View/Pages/home.ctp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/View/Pages/home.ctp b/app/View/Pages/home.ctp index f5c2ea226a7..d8b9d013d94 100644 --- a/app/View/Pages/home.ctp +++ b/app/View/Pages/home.ctp @@ -209,8 +209,8 @@ You can also add some CSS styles for your pages at: %s.',
  • -
  • CakePHP Official Forum -
    • CakePHP discussion forum
  • +
  • CakePHP Official Forum +
    • CakePHP discussion forum
  • irc.freenode.net #cakephp From b6d631b9879e8bf9df2246894fba06d0a0aa8413 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 3 May 2016 17:27:16 -0400 Subject: [PATCH 11/53] Use strlen(). Comparing a string against a length will not do the right thing. --- lib/Cake/Utility/Security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Utility/Security.php b/lib/Cake/Utility/Security.php index 01ade1ef984..464d05f7188 100644 --- a/lib/Cake/Utility/Security.php +++ b/lib/Cake/Utility/Security.php @@ -191,7 +191,7 @@ public static function randomBytes($length) { E_USER_WARNING ); $bytes = ''; - while ($bytes < $length) { + while (strlen($bytes) < $length) { $bytes .= static::hash(CakeText::uuid() . uniqid(mt_rand(), true), 'sha512', true); } return substr($bytes, 0, $length); From efc25266007bd364ab44e13adcedc4fbafce4675 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 3 May 2016 17:46:29 -0400 Subject: [PATCH 12/53] Appease PHPCS. --- lib/Cake/Utility/Security.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Utility/Security.php b/lib/Cake/Utility/Security.php index 464d05f7188..be128e64a24 100644 --- a/lib/Cake/Utility/Security.php +++ b/lib/Cake/Utility/Security.php @@ -191,8 +191,10 @@ public static function randomBytes($length) { E_USER_WARNING ); $bytes = ''; - while (strlen($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); } From de87ac1b5bcee0acde9a82e47a421ea0a50cb54a Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 3 May 2016 17:50:27 -0400 Subject: [PATCH 13/53] Remove link to google group. Refs #8763 --- app/View/Pages/home.ctp | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/View/Pages/home.ctp b/app/View/Pages/home.ctp index 52789d7be5f..f305fb3d4b0 100644 --- a/app/View/Pages/home.ctp +++ b/app/View/Pages/home.ctp @@ -211,8 +211,6 @@ You can also add some CSS styles for your pages at: %s.',
  • CakePHP Official Forum
    • CakePHP discussion forum
  • -
  • -
  • irc.freenode.net #cakephp From 4d65091d0c1cc0be5d7dfd4937bea7c94d3bc8ec Mon Sep 17 00:00:00 2001 From: xhs345 Date: Tue, 3 May 2016 15:39:37 -0700 Subject: [PATCH 14/53] Updated tests --- .../Test/Case/Console/Command/Task/ControllerTaskTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php index 9d8c9e2b28d..ded7e9596e7 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 @@ public function testDoHelpersTrailingCommas() { 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 @@ public function testDoComponentsTrailingSpaces() { $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 @@ public function testDoComponentsTrailingCommas() { $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); } From 4a61f7f23c726bd28fce3ad853268a9dd8419656 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 7 May 2016 02:42:37 -0400 Subject: [PATCH 15/53] Supporting APCu on PHP 7 --- .travis.yml | 2 + lib/Cake/Cache/Engine/ApcEngine.php | 53 +++++++++++++------ .../Test/Case/Cache/Engine/ApcEngineTest.php | 31 ++++++++--- 3 files changed, 63 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 900901156f3..c3492d555bb 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 " 'Apc'); parent::init($settings); + if (function_exists('apcu_dec')) { + $this->_apcExtension = 'apcu'; + return true; + } return function_exists('apc_dec'); } @@ -63,8 +74,8 @@ public function write($key, $value, $duration) { if ($duration) { $expires = time() + $duration; } - apc_store($key . '_expires', $expires, $duration); - return apc_store($key, $value, $duration); + $this->_apcCall('store', $key . '_expires', $expires, $duration); + return $this->_apcCall('store', $key, $value, $duration); } /** @@ -75,11 +86,11 @@ public function write($key, $value, $duration) { */ public function read($key) { $time = time(); - $cachetime = (int)apc_fetch($key . '_expires'); + $cachetime = (int)$this->_apcCall('fetch', $key . '_expires'); if ($cachetime !== 0 && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) { return false; } - return apc_fetch($key); + return $this->_apcCall('fetch', $key); } /** @@ -90,7 +101,7 @@ public function read($key) { * @return New incremented value, false otherwise */ public function increment($key, $offset = 1) { - return apc_inc($key, $offset); + return $this->_apcCall('inc', $key, $offset); } /** @@ -101,7 +112,7 @@ public function increment($key, $offset = 1) { * @return New decremented value, false otherwise */ public function decrement($key, $offset = 1) { - return apc_dec($key, $offset); + return $this->_apcCall('dec', $key, $offset); } /** @@ -111,7 +122,7 @@ public function decrement($key, $offset = 1) { * @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); + return $this->_apcCall('delete', $key); } /** @@ -131,13 +142,13 @@ public function clear($check) { '/^' . preg_quote($this->settings['prefix'], '/') . '/', APC_ITER_NONE ); - apc_delete($iterator); + $this->_apcCall('delete', $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']); + $this->_apcCall('delete', $key['info']); } } return true; @@ -157,11 +168,11 @@ public function groups() { } } - $groups = apc_fetch($this->_compiledGroupNames); + $groups = $this->_apcCall('fetch', $this->_compiledGroupNames); if (count($groups) !== count($this->settings['groups'])) { foreach ($this->_compiledGroupNames as $group) { if (!isset($groups[$group])) { - apc_store($group, 1); + $this->_apcCall('store', $group, 1); $groups[$group] = 1; } } @@ -184,7 +195,8 @@ public function groups() { * @return bool success */ public function clearGroup($group) { - apc_inc($this->settings['prefix'] . $group, 1, $success); + $func = function_exists('apc_inc') ? 'apc_inc' : 'apcu_inc'; + $func($this->settings['prefix'] . $group, 1, $success); return $success; } @@ -203,7 +215,18 @@ public function add($key, $value, $duration) { if ($duration) { $expires = time() + $duration; } - apc_add($key . '_expires', $expires, $duration); - return apc_add($key, $value, $duration); + $this->_apcCall('add', $key . '_expires', $expires, $duration); + return $this->_apcCall('add', $key, $value, $duration); + } + +/** + * Call APC(u) function + * + * @return mixed + */ + protected function _apcCall() { + $params = func_get_args(); + $func = $this->_apcExtension . '_' . array_shift($params); + return call_user_func_array($func, $params); } } diff --git a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php index 171e9d551bb..31d872e7b9d 100644 --- a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php @@ -32,7 +32,8 @@ 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.'); @@ -147,7 +148,8 @@ public function testDeleteCache() { * @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 +173,8 @@ public function testDecrement() { * @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 +198,14 @@ public function testIncrement() { * @return void */ public function testClear() { - apc_store('not_cake', 'survive'); + $this->_apcCall('store', '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', $this->_apcCall('fetch', 'not_cake')); + $this->_apcCall('delete', 'not_cake'); } /** @@ -222,12 +225,12 @@ public function testGroupsReadWrite() { $this->assertTrue(Cache::write('test_groups', 'value', 'apc_groups')); $this->assertEquals('value', Cache::read('test_groups', 'apc_groups')); - apc_inc('test_group_a'); + $this->_apcCall('inc', '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'); + $this->_apcCall('inc', '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')); @@ -292,4 +295,16 @@ public function testAdd() { $result = Cache::add('test_add_key', 'test data 2', 'apc'); $this->assertFalse($result); } + +/** + * Call APC/APCu function + * + * @return mixed + */ + protected function _apcCall() { + $params = func_get_args(); + $ext = extension_loaded('apc') ? 'apc' : 'apcu'; + $func = $ext . '_' . array_shift($params); + return call_user_func_array($func, $params); + } } From fa6e74ca22492becfee0d091671edbadae368b9d Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 7 May 2016 14:26:09 -0400 Subject: [PATCH 16/53] Improved apc calls Instead of calling the call_user_func_array it does the call directly. It is a little bit more verbose, but performs better. --- lib/Cake/Cache/Engine/ApcEngine.php | 48 +++++++++---------- .../Test/Case/Cache/Engine/ApcEngineTest.php | 38 ++++++++------- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/lib/Cake/Cache/Engine/ApcEngine.php b/lib/Cake/Cache/Engine/ApcEngine.php index cd93c829395..8500560dfe5 100644 --- a/lib/Cake/Cache/Engine/ApcEngine.php +++ b/lib/Cake/Cache/Engine/ApcEngine.php @@ -74,8 +74,9 @@ public function write($key, $value, $duration) { if ($duration) { $expires = time() + $duration; } - $this->_apcCall('store', $key . '_expires', $expires, $duration); - return $this->_apcCall('store', $key, $value, $duration); + $func = $this->_apcExtension . '_store'; + $func($key . '_expires', $expires, $duration); + return $func($key, $value, $duration); } /** @@ -86,11 +87,12 @@ public function write($key, $value, $duration) { */ public function read($key) { $time = time(); - $cachetime = (int)$this->_apcCall('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 $this->_apcCall('fetch', $key); + return $func($key); } /** @@ -101,7 +103,8 @@ public function read($key) { * @return New incremented value, false otherwise */ public function increment($key, $offset = 1) { - return $this->_apcCall('inc', $key, $offset); + $func = $this->_apcExtension . '_inc'; + return $func($key, $offset); } /** @@ -112,7 +115,8 @@ public function increment($key, $offset = 1) { * @return New decremented value, false otherwise */ public function decrement($key, $offset = 1) { - return $this->_apcCall('dec', $key, $offset); + $func = $this->_apcExtension . '_dec'; + return $func($key, $offset); } /** @@ -122,7 +126,8 @@ public function decrement($key, $offset = 1) { * @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 $this->_apcCall('delete', $key); + $func = $this->_apcExtension . '_delete'; + return $func($key); } /** @@ -136,19 +141,20 @@ public function clear($check) { 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 ); - $this->_apcCall('delete', $iterator); + $func($iterator); return true; } $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) { - $this->_apcCall('delete', $key['info']); + $func($key['info']); } } return true; @@ -168,11 +174,13 @@ public function groups() { } } - $groups = $this->_apcCall('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])) { - $this->_apcCall('store', $group, 1); + $storeFunc($group, 1); $groups[$group] = 1; } } @@ -195,7 +203,7 @@ public function groups() { * @return bool success */ public function clearGroup($group) { - $func = function_exists('apc_inc') ? 'apc_inc' : 'apcu_inc'; + $func = $this->_apcExtension . '_inc'; $func($this->settings['prefix'] . $group, 1, $success); return $success; } @@ -215,18 +223,8 @@ public function add($key, $value, $duration) { if ($duration) { $expires = time() + $duration; } - $this->_apcCall('add', $key . '_expires', $expires, $duration); - return $this->_apcCall('add', $key, $value, $duration); - } - -/** - * Call APC(u) function - * - * @return mixed - */ - protected function _apcCall() { - $params = func_get_args(); - $func = $this->_apcExtension . '_' . array_shift($params); - return call_user_func_array($func, $params); + $func = $this->_apcExtension . '_add'; + $func($key . '_expires', $expires, $duration); + return $func($key, $value, $duration); } } diff --git a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php index 31d872e7b9d..6ae6d643a74 100644 --- a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php @@ -25,6 +25,13 @@ */ class ApcEngineTest extends CakeTestCase { +/** + * APC extension to be used + * + * @var string + */ + protected $_apcExtension = 'apc'; + /** * setUp method * @@ -39,6 +46,10 @@ public function setUp() { $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_')); @@ -198,14 +209,18 @@ public function testIncrement() { * @return void */ public function testClear() { - $this->_apcCall('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', $this->_apcCall('fetch', 'not_cake')); - $this->_apcCall('delete', 'not_cake'); + $this->assertEquals('survive', $fetchFunc('not_cake')); + $deleteFunc('not_cake'); } /** @@ -216,6 +231,7 @@ public function testClear() { * @return void */ public function testGroupsReadWrite() { + $incFunc = $this->_apcExtension . '_inc'; Cache::config('apc_groups', array( 'engine' => 'Apc', 'duration' => 0, @@ -225,12 +241,12 @@ public function testGroupsReadWrite() { $this->assertTrue(Cache::write('test_groups', 'value', 'apc_groups')); $this->assertEquals('value', Cache::read('test_groups', 'apc_groups')); - $this->_apcCall('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')); - $this->_apcCall('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')); @@ -295,16 +311,4 @@ public function testAdd() { $result = Cache::add('test_add_key', 'test data 2', 'apc'); $this->assertFalse($result); } - -/** - * Call APC/APCu function - * - * @return mixed - */ - protected function _apcCall() { - $params = func_get_args(); - $ext = extension_loaded('apc') ? 'apc' : 'apcu'; - $func = $ext . '_' . array_shift($params); - return call_user_func_array($func, $params); - } } From 39b4cbebb368757e740da9c0743abb211a5509cd Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 8 May 2016 15:36:28 -0400 Subject: [PATCH 17/53] Port PHP7 fixes to 2.x Port the fixes @ADmad did in 8f150dc5 to 2.x so those builds start to pass once again. --- lib/Cake/Network/CakeRequest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 8bd2b3c5074..4b266cb8319 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -1124,6 +1124,9 @@ public function offsetSet($name, $value) { * @return bool */ public function offsetExists($name) { + if ($name === 'url' || $name === 'data') { + return true; + } return isset($this->params[$name]); } From 723ed96fd6f529e7dfa420bbb146c95d2bc47268 Mon Sep 17 00:00:00 2001 From: Steampilot Date: Thu, 12 May 2016 16:28:04 +0200 Subject: [PATCH 18/53] Added sorting by modified time in Folder util --- lib/Cake/Test/Case/Utility/FolderTest.php | 81 +++++++++++++++++++++++ lib/Cake/Utility/Folder.php | 43 ++++++++++-- 2 files changed, 118 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 55292281803..1d53713ae86 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -1227,4 +1227,85 @@ public function testMoveWithSkip() { $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/Utility/Folder.php b/lib/Cake/Utility/Folder.php index e23f70e5a72..1b59ba15554 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 @@ public function cd($path) { * 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 @@ public function read($sort = true, $exceptions = false, $fullPath = false) { } 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 @@ public function read($sort = true, $exceptions = false, $fullPath = false) { $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); } From c02b269bcb85d45b37235248ac7515b8cd338198 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 17 May 2016 22:24:00 -0400 Subject: [PATCH 19/53] Fix default installation path for vendors. By default global vendors go into `/vendors`. This config change helps people get started with less friction. I've removed debugkit as a dependency, as it isn't _really_ a dependency for CakePHP itself. Refs #8765 --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5c2ac669232..3f3ead20804 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" ] From c7a48acd104ea5f9d9f43d273d157d842d95f7e2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 17 May 2016 22:29:59 -0400 Subject: [PATCH 20/53] Add composer.json for the app/ This will act as a stub for developers to extend and improve upon when they build their apps. Hopefully people don't find the two composer.json files overly confusing. Refs #8765 --- app/composer.json | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 app/composer.json diff --git a/app/composer.json b/app/composer.json new file mode 100644 index 00000000000..fb361fc5df5 --- /dev/null +++ b/app/composer.json @@ -0,0 +1,35 @@ +{ + "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", + "cakephp/cakephp-codesniffer": "^1.0.0" + }, + "bin": [ + "lib/Cake/Console/cake" + ], + "config": { + "vendor-dir": "Vendor/" + } +} From e31ce0d58fdbac77da609dc8e4628962c38ecd05 Mon Sep 17 00:00:00 2001 From: Richard Torenvliet Date: Wed, 18 May 2016 14:54:52 +0200 Subject: [PATCH 21/53] Add the HTTP Patch to the Content-Type check mechanism Currently when a request is of type 'patch' it is ignored. This commit makes sure that the Content-Type is checked when a patch request is provided. --- lib/Cake/Controller/Component/RequestHandlerComponent.php | 7 ++++++- lib/Cake/Network/CakeRequest.php | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index ea1d727045b..9c3bc56a283 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -505,7 +505,12 @@ public function accepts($type = null) { * 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/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 8bd2b3c5074..adaa74dd86c 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'), From 615be3ad1425531160ad7f133b39edfab17151c5 Mon Sep 17 00:00:00 2001 From: xhs345 Date: Wed, 18 May 2016 10:53:06 -0700 Subject: [PATCH 22/53] Fix for Issue #8847 Add attribute 'fieldset' to Form->radio --- lib/Cake/View/Helper/FormHelper.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 5cad0468891..974c54c650a 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1510,6 +1510,7 @@ public function checkbox($fieldName, $options = array()) { * - `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 @@ -1544,6 +1545,12 @@ public function radio($fieldName, $options = array(), $attributes = array()) { $legend = __(Inflector::humanize($this->field())); } + $fieldset = ''; + if (isset($attributes['fieldset'])) { + $fieldset = $attributes['fieldset']; + unset($attributes['fieldset']); + } + $label = true; if (isset($attributes['label'])) { $label = $attributes['label']; @@ -1638,7 +1645,12 @@ public function radio($fieldName, $options = array(), $attributes = array()) { $between = ''; } if ($legend) { - $out = $this->Html->useTag('fieldset', '', $this->Html->useTag('legend', $legend) . $between . $out); + if (is_string($fieldset)) { + $fieldsetClass = sprintf(' class="%s"', $fieldset); + } else { + $fieldsetClass = ''; + } + $out = $this->Html->useTag('fieldset', $fieldsetClass, $this->Html->useTag('legend', $legend) . $between . $out); } return $out; } From f75ebf8cb9523d00c3714a4ebac18c418d5f9745 Mon Sep 17 00:00:00 2001 From: Markus Bauer Date: Wed, 18 May 2016 23:46:10 +0200 Subject: [PATCH 23/53] Make Sqlite Testcases compatible with Windows / NTFS file systems --- .../Test/Case/Model/Datasource/Database/SqliteTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php index 14758c7d7ac..3f23c456a94 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 @@ public function testCacheKeyName() { $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));"); From 058809275c441958ffa9a061d82e4690628c448e Mon Sep 17 00:00:00 2001 From: Markus Bauer Date: Wed, 18 May 2016 23:46:51 +0200 Subject: [PATCH 24/53] Enable nested transactions before trying to test them --- lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php index 3f23c456a94..995eb3d0c0d 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php @@ -472,6 +472,7 @@ public function testUuidPrimaryKeyInsertion() { * @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'); From 2227e019903a8183c25f11a5cf6c2abcdab45a74 Mon Sep 17 00:00:00 2001 From: Markus Bauer Date: Thu, 19 May 2016 00:21:43 +0200 Subject: [PATCH 25/53] Fixing Sqlite's handling of datetime/timestamp columns with current_timestamp default set --- lib/Cake/Model/Datasource/Database/Sqlite.php | 3 ++ .../Model/Datasource/Database/SqliteTest.php | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index 9bdc81c4cf7..7dd81f8a461 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -185,6 +185,9 @@ public function describe($model) { '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/Test/Case/Model/Datasource/Database/SqliteTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php index 14758c7d7ac..c60d936ad40 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php @@ -422,6 +422,40 @@ public function testDescribeWithUuidPrimaryKey() { $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. * From 0d32554546f13f7116c9c411d48b60aa53e75b47 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 18 May 2016 22:07:33 -0400 Subject: [PATCH 26/53] Move codesniffer into suggests. Not everyone will want/need the codesniffer. --- app/composer.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/composer.json b/app/composer.json index fb361fc5df5..e05128e7247 100644 --- a/app/composer.json +++ b/app/composer.json @@ -23,8 +23,10 @@ }, "require-dev": { "phpunit/phpunit": "3.7.*", - "cakephp/cakephp": "~2.8", - "cakephp/cakephp-codesniffer": "^1.0.0" + "cakephp/cakephp": "~2.8" + }, + "suggest": { + "cakephp/cakephp-codesniffer": "Easily check code formatting against the CakePHP coding standards." }, "bin": [ "lib/Cake/Console/cake" From dcd756370744098bff365ba751539ba153fd0442 Mon Sep 17 00:00:00 2001 From: xhs345 Date: Wed, 18 May 2016 23:04:23 -0700 Subject: [PATCH 27/53] Rewrote class attribute assignment --- lib/Cake/View/Helper/FormHelper.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 974c54c650a..99dbe09466c 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -932,11 +932,14 @@ public function inputs($fields = null, $blacklist = null, $options = array()) { if (isset($options['legend'])) { $legend = $options['legend']; + unset($options['legend']); } if (isset($options['fieldset'])) { - $fieldset = $options['fieldset']; + $fieldsetAttrs = ['class' => $options['fieldset']]; + unset($options['fieldset']); } + if (empty($fields)) { $fields = $modelFields; } @@ -971,17 +974,13 @@ public function inputs($fields = null, $blacklist = null, $options = array()) { $out .= $this->input($name, $options); } - if (is_string($fieldset)) { - $fieldsetClass = sprintf(' class="%s"', $fieldset); - } else { - $fieldsetClass = ''; - } + if ($fieldset) { if ($legend) { $out = $this->Html->useTag('legend', $legend) . $out; } - $out = $this->Html->useTag('fieldset', $fieldsetClass, $out); + $out = $this->Html->useTag('fieldset', $fieldsetAttrs, $out); } return $out; } @@ -1545,9 +1544,9 @@ public function radio($fieldName, $options = array(), $attributes = array()) { $legend = __(Inflector::humanize($this->field())); } - $fieldset = ''; + $fieldsetAttrs = ''; if (isset($attributes['fieldset'])) { - $fieldset = $attributes['fieldset']; + $fieldsetAttrs = ['class' => $attributes['fieldset']]; unset($attributes['fieldset']); } @@ -1644,13 +1643,10 @@ public function radio($fieldName, $options = array(), $attributes = array()) { if (is_array($between)) { $between = ''; } + if ($legend) { - if (is_string($fieldset)) { - $fieldsetClass = sprintf(' class="%s"', $fieldset); - } else { - $fieldsetClass = ''; - } - $out = $this->Html->useTag('fieldset', $fieldsetClass, $this->Html->useTag('legend', $legend) . $between . $out); + $out = $this->Html->useTag('legend', $legend) . $between . $out; + $out = $this->Html->useTag('fieldset', $fieldsetAttrs, $out); } return $out; } From eeefa03546260a7f60faf343efd9ea9bb00036af Mon Sep 17 00:00:00 2001 From: xhs345 Date: Thu, 19 May 2016 17:28:47 -0700 Subject: [PATCH 28/53] Updated Radio and Inputs form helper Also added UnitTest for radio fieldset class-name --- .../Test/Case/View/Helper/FormHelperTest.php | 19 +++++++++++++ lib/Cake/View/Helper/FormHelper.php | 27 ++++++++++--------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index c2627b8d3db..7db56739ab9 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -3914,6 +3914,25 @@ public function testRadio() { ); $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/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 974c54c650a..4710b897709 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -932,11 +932,15 @@ public function inputs($fields = null, $blacklist = null, $options = array()) { if (isset($options['legend'])) { $legend = $options['legend']; + unset($options['legend']); } + if (isset($options['fieldset'])) { $fieldset = $options['fieldset']; + unset($options['fieldset']); } + if (empty($fields)) { $fields = $modelFields; } @@ -971,11 +975,11 @@ public function inputs($fields = null, $blacklist = null, $options = array()) { $out .= $this->input($name, $options); } - if (is_string($fieldset)) { - $fieldsetClass = sprintf(' class="%s"', $fieldset); - } else { - $fieldsetClass = ''; - } + if (is_string($fieldset)) { + $fieldsetClass = array('class' => $fieldset); + } else { + $fieldsetClass = ''; + } if ($fieldset) { if ($legend) { @@ -1545,9 +1549,9 @@ public function radio($fieldName, $options = array(), $attributes = array()) { $legend = __(Inflector::humanize($this->field())); } - $fieldset = ''; + $fieldsetAttrs = ''; if (isset($attributes['fieldset'])) { - $fieldset = $attributes['fieldset']; + $fieldsetAttrs = array('class' => $attributes['fieldset']); unset($attributes['fieldset']); } @@ -1644,13 +1648,10 @@ public function radio($fieldName, $options = array(), $attributes = array()) { if (is_array($between)) { $between = ''; } + if ($legend) { - if (is_string($fieldset)) { - $fieldsetClass = sprintf(' class="%s"', $fieldset); - } else { - $fieldsetClass = ''; - } - $out = $this->Html->useTag('fieldset', $fieldsetClass, $this->Html->useTag('legend', $legend) . $between . $out); + $out = $this->Html->useTag('legend', $legend) . $between . $out; + $out = $this->Html->useTag('fieldset', $fieldsetAttrs, $out); } return $out; } From 850305a3840adfb1cb8d8b029f6958613fac4ed5 Mon Sep 17 00:00:00 2001 From: nojimage Date: Sat, 21 May 2016 13:33:20 +0900 Subject: [PATCH 29/53] fixes reset FormHelper::$_unlockFields --- .../Test/Case/View/Helper/FormHelperTest.php | 20 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 1 + 2 files changed, 21 insertions(+) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 2ca6217122c..b478abff842 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -1597,6 +1597,26 @@ public function testUnlockFieldRemovingFromFields() { $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->create('Contact'); + $this->Form->unlockField('Contact.id'); + $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 * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 5d583a9c440..72c24878592 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -466,6 +466,7 @@ public function create($model = null, $options = array()) { $htmlAttributes = array_merge($options, $htmlAttributes); $this->fields = array(); + $this->_unlockedFields = array(); if ($this->requestType !== 'get') { $append .= $this->_csrfField(); } From d5d46e21bd36753baa285c23fabcb392f6ba71ad Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 22 May 2016 16:39:49 -0400 Subject: [PATCH 30/53] Fix indentation. --- .../Test/Case/View/Helper/FormHelperTest.php | 36 +++++++++---------- lib/Cake/View/Helper/FormHelper.php | 10 +++--- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 7db56739ab9..4848e457715 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -3914,24 +3914,24 @@ public function testRadio() { ); $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('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', diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 4710b897709..9625fc09f0b 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -975,11 +975,11 @@ public function inputs($fields = null, $blacklist = null, $options = array()) { $out .= $this->input($name, $options); } - if (is_string($fieldset)) { - $fieldsetClass = array('class' => $fieldset); - } else { - $fieldsetClass = ''; - } + if (is_string($fieldset)) { + $fieldsetClass = array('class' => $fieldset); + } else { + $fieldsetClass = ''; + } if ($fieldset) { if ($legend) { From e78af35af77348549b56ba222339c290f23a880b Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 25 May 2016 23:04:53 +0200 Subject: [PATCH 31/53] Only clear the unlocked fields on end(). Doing this work on end() allows fields to be unlocked before the form is created which can be helpful. Refs #8880 --- lib/Cake/Test/Case/View/Helper/FormHelperTest.php | 4 +++- lib/Cake/View/Helper/FormHelper.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index a30cc919fed..f72ea120d26 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -1608,8 +1608,10 @@ public function testResetUnlockFields() { 'unlockedFields' => array() ); - $this->Form->create('Contact'); $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'); diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 31b18010fa3..2282a38e5e6 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -467,7 +467,6 @@ public function create($model = null, $options = array()) { $htmlAttributes = array_merge($options, $htmlAttributes); $this->fields = array(); - $this->_unlockedFields = array(); if ($this->requestType !== 'get') { $append .= $this->_csrfField(); } @@ -561,6 +560,7 @@ public function end($options = null, $secureAttributes = array()) { $this->setEntity(null); $out .= $this->Html->useTag('formend'); + $this->_unlockedFields = array(); $this->_View->modelScope = false; $this->requestType = null; return $out; From 8c73086717762db1b5abaf7a803f1b14f86cb482 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 25 May 2016 23:05:12 +0200 Subject: [PATCH 32/53] Fix PHPCS error. --- lib/Cake/View/Helper/FormHelper.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 2282a38e5e6..f52b74dedc5 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -941,7 +941,6 @@ public function inputs($fields = null, $blacklist = null, $options = array()) { unset($options['fieldset']); } - if (empty($fields)) { $fields = $modelFields; } From b737e9f73260204db55f4a60990d4e7c593103f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Th=C3=A9venot?= Date: Fri, 27 May 2016 12:50:23 +0000 Subject: [PATCH 33/53] #8844 Add test --- .../Case/Controller/Component/RequestHandlerComponentTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php index 1e9f8daaf69..028729fae38 100644 --- a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php @@ -618,6 +618,9 @@ public function testRequestContentTypes() { $_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'; From c2bc45ac42536b4dc49cd26caf3450bd0f467b65 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 29 May 2016 16:29:05 +0200 Subject: [PATCH 34/53] Remove old logo from README. --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index d427d607d23..4e1ccb19bf8 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ [![Bake Status](https://secure.travis-ci.org/cakephp/cakephp.png?branch=master)](http://travis-ci.org/cakephp/cakephp) [![Code consistency](http://squizlabs.github.io/PHP_CodeSniffer/analysis/cakephp/cakephp/grade.svg)](http://squizlabs.github.io/PHP_CodeSniffer/analysis/cakephp/cakephp/) -[![CakePHP](http://cakephp.org/img/cake-logo.png)](http://www.cakephp.org) - CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility. From 7055e82eab7effa5c2f7406ca28d4d396314bc65 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 2 Jun 2016 22:04:50 -0400 Subject: [PATCH 35/53] Add missing uses() call. Refs #8929 --- lib/Cake/Network/Email/DebugTransport.php | 1 + lib/Cake/Network/Email/MailTransport.php | 1 + lib/Cake/Network/Email/SmtpTransport.php | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Network/Email/DebugTransport.php b/lib/Cake/Network/Email/DebugTransport.php index 5f6ae298dba..8ab64e1b007 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 9e27899d3a9..3b40f21c133 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 64d0090b57c..c581c9a2f52 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'); /** From 64e7c8d9914c845efa8d1865fe0472fd6b6706b6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Jun 2016 22:15:08 -0400 Subject: [PATCH 36/53] Update version number to 2.8.5 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 5922b09f5ac..9a3a91b5ce0 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.4 +2.8.5 From d352b5f14d96885e6b02b8ecd4bfeed5af7e52ec Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Jun 2016 22:17:04 -0400 Subject: [PATCH 37/53] Correct domain name used to upload pear packages. --- build.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.xml b/build.xml index 786916b99d4..98c48bae936 100644 --- a/build.xml +++ b/build.xml @@ -213,10 +213,10 @@ --> - + - + From 449e5fc9cf9020b62d8ed4da074e10cadfe9d95e Mon Sep 17 00:00:00 2001 From: kolorafa Date: Mon, 13 Jun 2016 18:02:26 +0200 Subject: [PATCH 38/53] Can't override CakeEmail class and use deliver When using TemplateEmail::deliver it always create new instance of CakeEmail, I assume it should create my extended "TemplateEmail" class insted. PHP >5.3 compatible --- lib/Cake/Network/Email/CakeEmail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index bf62be85a5b..33e37ca68c3 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1203,7 +1203,7 @@ public function send($content = null) { * @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) { From 0bf38c1ee476d1e20e81f13de364a9df9d943d50 Mon Sep 17 00:00:00 2001 From: chinpei215 Date: Thu, 16 Jun 2016 12:12:37 +0900 Subject: [PATCH 39/53] Fix misnamed variable in default home.ctp PDO error message wouldn't appear when using PHP 5.4 or later. --- app/View/Pages/home.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/View/Pages/home.ctp b/app/View/Pages/home.ctp index f305fb3d4b0..6874017923e 100644 --- a/app/View/Pages/home.ctp +++ b/app/View/Pages/home.ctp @@ -94,7 +94,7 @@ if (isset($filePresent)): $errorMsg = $connectionError->getMessage(); if (method_exists($connectionError, 'getAttributes')): $attributes = $connectionError->getAttributes(); - if (isset($errorMsg['message'])): + if (isset($attributes['message'])): $errorMsg .= '
    ' . $attributes['message']; endif; endif; From 92a50d05dcd820434e0799d9c22beb823a590bf1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 22 Jun 2016 22:20:00 -0400 Subject: [PATCH 40/53] Reset query timing metrics for begin/commit/insert multi calls. Apply patch from @Mensler to reset the query metrics for transaction operations, and for each iteration of an insertMulti call. This helps provide more accurate query times. Refs #9014 --- lib/Cake/Model/Datasource/DboSource.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 357f902e834..bdd76e98641 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -2302,6 +2302,7 @@ public function begin() { $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 @@ public function begin() { 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 @@ public function commit() { if ($this->_transactionNesting === 0) { if ($this->fullDebug) { + $this->took = $this->numRows = $this->affected = false; $this->logQuery('COMMIT'); } $this->_transactionStarted = false; @@ -2357,6 +2360,7 @@ public function commit() { 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 @@ public function rollback() { if ($this->_transactionNesting === 0) { if ($this->fullDebug) { + $this->took = $this->numRows = $this->affected = false; $this->logQuery('ROLLBACK'); } $this->_transactionStarted = false; @@ -2399,6 +2404,7 @@ public function rollback() { 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 @@ public function insertMulti($table, $fields, $values) { $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); } } From 2c112095a94706f0a438478fe714908f67786228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20In=20The=20Cloud?= Date: Mon, 27 Jun 2016 14:15:05 -0400 Subject: [PATCH 41/53] Issue #9040 - Auth saving json in Auth.redirect AuthComponent is storing JSON or any other AJAX request URL into the session variable Auth.redirect used for login redirect if the AJAX request does not send the X-Requested-With:XMLHttpRequest header. If you send an ajax request without that header and your request is not a (.json) it will store the URL anyway. --- lib/Cake/Controller/Component/AuthComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 3381d68f1fc..1b65fd921bc 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -359,7 +359,7 @@ protected function _unauthenticated(Controller $controller) { return true; } - if (!$controller->request->is('ajax')) { + if (!$controller->request->is('ajax') && !$controller->request->is('json')) { $this->flash($this->authError); $this->Session->write('Auth.redirect', $controller->request->here(false)); $controller->redirect($this->loginAction); From f28c21c7a7be5c5fddaffdc69c861da607ca657e Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Jun 2016 21:47:37 -0400 Subject: [PATCH 42/53] Stop testing against SSL ciphers that emit warnings. Testing that SSLv3 still works is causing test failures. --- lib/Cake/Test/Case/Network/CakeSocketTest.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/Cake/Test/Case/Network/CakeSocketTest.php b/lib/Cake/Test/Case/Network/CakeSocketTest.php index e93882d06a1..c678d9c5b72 100644 --- a/lib/Cake/Test/Case/Network/CakeSocketTest.php +++ b/lib/Cake/Test/Case/Network/CakeSocketTest.php @@ -318,11 +318,6 @@ public function testEnableCryptoBadMode() { * @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')); From 57e0a9748308557a89f09521a56bfd1111430155 Mon Sep 17 00:00:00 2001 From: nojimage Date: Sat, 21 May 2016 11:01:49 +0900 Subject: [PATCH 43/53] refs #8654 FormHelper cleanup unlockFields key --- .../Test/Case/View/Helper/FormHelperTest.php | 23 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index f72ea120d26..6ca879919db 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -1619,6 +1619,29 @@ public function testResetUnlockFields() { $this->assertEquals(1, $this->Form->fields['Contact.id'], 'Hidden input should be secured.'); } +/** + * test unlockField removing from fields array. multiple field version. + * + * @return void + */ + public function testUnlockMultipleFieldRemovingFromFields() { + $this->Form->request['_Token'] = array( + 'key' => 'testKey', + 'unlockedFields' => array() + ); + $this->Form->create('Order'); + $this->Form->hidden('Order.id', array('value' => 1)); + $this->Form->checkbox('Ticked.id.'); + $this->Form->checkbox('Ticked.id.'); + + $this->assertEquals(1, $this->Form->fields['Order.id'], 'Hidden input should be secured.'); + $this->assertTrue(in_array('Ticked.id', $this->Form->fields), 'Field should be secured.'); + + $this->Form->unlockField('Order.id'); + $this->Form->unlockField('Ticked.id'); + $this->assertEquals(array(), $this->Form->fields); + } + /** * testTagIsInvalid method * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index f52b74dedc5..e4cbfda9c31 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -666,6 +666,10 @@ protected function _secure($lock, $field = null, $value = null) { $field = Hash::filter(explode('.', $field)); } + if (is_array($field)) { + $field = array_filter($field, 'strlen'); + } + foreach ($this->_unlockedFields as $unlockField) { $unlockParts = explode('.', $unlockField); if (array_values(array_intersect($field, $unlockParts)) === $unlockParts) { From 7c2d6ae1977c9c135de95177c488b1a8875fc9d6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 28 Jun 2016 22:06:53 -0400 Subject: [PATCH 44/53] Combine code paths. At the end of both if/else arms we should have an array that can be pushed through Hash::filter(). Refs #8654 --- lib/Cake/View/Helper/FormHelper.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index e4cbfda9c31..ea190ca6bf9 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -663,11 +663,10 @@ protected function _secure($lock, $field = null, $value = null) { if (!$field) { $field = $this->entity(); } elseif (is_string($field)) { - $field = Hash::filter(explode('.', $field)); + $field = explode('.', $field); } - if (is_array($field)) { - $field = array_filter($field, 'strlen'); + $field = Hash::filter($field); } foreach ($this->_unlockedFields as $unlockField) { From 3a42ecc61cdd73b853375f5512724cf775f6bcb1 Mon Sep 17 00:00:00 2001 From: Alex Para Date: Fri, 1 Jul 2016 11:11:16 +0300 Subject: [PATCH 45/53] fixes #9064 - added new locale for Icelandic language --- lib/Cake/I18n/L10n.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/I18n/L10n.php b/lib/Cake/I18n/L10n.php index 7e57a36fbd0..d2d5405590b 100644 --- a/lib/Cake/I18n/L10n.php +++ b/lib/Cake/I18n/L10n.php @@ -272,6 +272,7 @@ class L10n { 'hy' => array('language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8', 'direction' => 'ltr'), 'id' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'), 'is' => array('language' => 'Icelandic', 'locale' => 'isl', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'is-is' => array('language' => 'Icelandic', 'locale' => 'is_is', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'), 'it' => array('language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'), 'it-ch' => array('language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'), 'ja' => array('language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8', 'direction' => 'ltr'), From 58a31ecfe5bccaaf8f2a71c070ac517d1fed7d76 Mon Sep 17 00:00:00 2001 From: Alex Para Date: Fri, 1 Jul 2016 14:46:27 +0300 Subject: [PATCH 46/53] fixes #9064 --- lib/Cake/I18n/L10n.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/I18n/L10n.php b/lib/Cake/I18n/L10n.php index d2d5405590b..a87be16c022 100644 --- a/lib/Cake/I18n/L10n.php +++ b/lib/Cake/I18n/L10n.php @@ -272,7 +272,7 @@ class L10n { 'hy' => array('language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8', 'direction' => 'ltr'), 'id' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'), 'is' => array('language' => 'Icelandic', 'locale' => 'isl', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'is-is' => array('language' => 'Icelandic', 'locale' => 'is_is', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'), + 'is-is' => array('language' => 'Icelandic (Iceland)', 'locale' => 'is_is', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'), 'it' => array('language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'), 'it-ch' => array('language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'), 'ja' => array('language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8', 'direction' => 'ltr'), From e6a3bdf954107f77b53302c8d595b024f989e754 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 1 Jul 2016 17:28:50 +0530 Subject: [PATCH 47/53] Make stickler ignore 2.x and 2.next branches. --- .stickler.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .stickler.yml diff --git a/.stickler.yml b/.stickler.yml new file mode 100644 index 00000000000..61243f09079 --- /dev/null +++ b/.stickler.yml @@ -0,0 +1,2 @@ +branches: + ignore: ['2.x', '2.next'] From d816ea6e1603f10c7878c4bb2af74daf4c9a78eb Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 30 Jun 2016 23:08:43 -0400 Subject: [PATCH 48/53] Add test showing that niceShort translates month names. Refs #8968 --- lib/Cake/Test/Case/Utility/CakeTimeTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index 2620f789707..f5741272fb3 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -454,6 +454,17 @@ public function testNiceShort() { $this->_restoreSystemTimezone(); } +/** + * testNiceShort translations + * + * @return void + */ + public function testNiceShortI18n() { + setlocale(LC_ALL, 'es_ES'); + $time = strtotime('2015-01-07 03:05:00'); + $this->assertEquals('ene 7th 2015, 03:05', $this->Time->niceShort($time)); + } + /** * testDaysAsSql method * From 234f732d6dfec0c1ddfc59abb0530a1194241e57 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 1 Jul 2016 17:15:23 -0400 Subject: [PATCH 49/53] Attempt to get tests passing on travis. Also attempt to get stickler to ignore the 2.x branch. --- .travis.yml | 1 + lib/Cake/Test/Case/Utility/CakeTimeTest.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index c3492d555bb..b43db1d259b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,7 @@ before_script: - sh -c "composer global require 'phpunit/phpunit=3.7.33'" - sh -c "ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit" - sudo locale-gen de_DE + - sudo locale-gen es_ES - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi" - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi" - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test3;'; fi" diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index f5741272fb3..dc2a8887c6d 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -460,9 +460,11 @@ public function testNiceShort() { * @return void */ public function testNiceShortI18n() { + $restore = setlocale(LC_ALL, 0); setlocale(LC_ALL, 'es_ES'); $time = strtotime('2015-01-07 03:05:00'); $this->assertEquals('ene 7th 2015, 03:05', $this->Time->niceShort($time)); + setlocale(LC_ALL, $restore); } /** From f22129b9c73734b3c62dc5570d290f02d67c9bf1 Mon Sep 17 00:00:00 2001 From: Kim Biesbjerg Date: Wed, 6 Jul 2016 00:25:46 +0200 Subject: [PATCH 50/53] Store user data in memory on login for stateless auth adapters --- lib/Cake/Controller/Component/AuthComponent.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 1b65fd921bc..3e62e2cc9b6 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -611,8 +611,12 @@ public function login($user = null) { $user = $this->identify($this->request, $this->response); } if ($user) { - $this->Session->renew(); - $this->Session->write(static::$sessionKey, $user); + if (static::$sessionKey) { + $this->Session->renew(); + $this->Session->write(static::$sessionKey, $user); + } else { + static::$_user = $user; + } $event = new CakeEvent('Auth.afterIdentify', $this, array('user' => $user)); $this->_Collection->getController()->getEventManager()->dispatch($event); } From c63de8d9f578cab2372b5e938b6b9aba0382c66d Mon Sep 17 00:00:00 2001 From: Kim Biesbjerg Date: Wed, 6 Jul 2016 12:34:23 +0200 Subject: [PATCH 51/53] Added test to prove stateless login sets user --- .../Component/AuthComponentTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 0ff514df614..80d6cda58f8 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -1721,6 +1721,25 @@ public function testStatelessAuthNoRedirect() { $this->Auth->startup($this->Controller); } +/** + * testStatelessLoginSetsUser method + * + * @return void + */ + public function testStatelessLoginSetsUser() { + $user = array( + 'id' => 1, + 'username' => 'mark' + ); + + AuthComponent::$sessionKey = false; + $result = $this->Auth->login($user); + $this->assertTrue($result); + + $this->assertTrue($this->Auth->loggedIn()); + $this->assertEquals($user, $this->Auth->user()); + } + /** * testStatelessAuthNoSessionStart method * From 0ea315b2e0c927e06ffeb1b1993c9cc8506ed08e Mon Sep 17 00:00:00 2001 From: Kim Biesbjerg Date: Thu, 7 Jul 2016 08:58:51 +0200 Subject: [PATCH 52/53] Add assertion to prove session is not started on stateless login --- .../Test/Case/Controller/Component/AuthComponentTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 80d6cda58f8..33292662fb6 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -1722,11 +1722,11 @@ public function testStatelessAuthNoRedirect() { } /** - * testStatelessLoginSetsUser method + * testStatelessLoginSetUserNoSessionStart method * * @return void */ - public function testStatelessLoginSetsUser() { + public function testStatelessLoginSetUserNoSessionStart() { $user = array( 'id' => 1, 'username' => 'mark' @@ -1738,6 +1738,8 @@ public function testStatelessLoginSetsUser() { $this->assertTrue($this->Auth->loggedIn()); $this->assertEquals($user, $this->Auth->user()); + + $this->assertNull($this->Auth->Session->started()); } /** From 1d7a4da903e2b11c948f2ff4541f44c8eb481b27 Mon Sep 17 00:00:00 2001 From: Kim Biesbjerg Date: Thu, 7 Jul 2016 09:24:33 +0200 Subject: [PATCH 53/53] Fixed wrong assertion --- lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 33292662fb6..00e1b35598f 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -1739,7 +1739,7 @@ public function testStatelessLoginSetUserNoSessionStart() { $this->assertTrue($this->Auth->loggedIn()); $this->assertEquals($user, $this->Auth->user()); - $this->assertNull($this->Auth->Session->started()); + $this->assertFalse($this->Auth->Session->started()); } /**