From 29570e1d99bac3253c8079cf1651ace58ff8befc Mon Sep 17 00:00:00 2001 From: "Angel S. Moreno" Date: Sat, 6 Sep 2014 18:32:45 -0400 Subject: [PATCH 01/13] Fixed overwriting of files when Folder::SKIP is set --- lib/Cake/Utility/Folder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index f79c4ac51..7d768dff4 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -673,7 +673,7 @@ class Folder { $to = Folder::addPathElement($toDir, $item); if (($options['scheme'] != Folder::SKIP || !is_dir($to)) && !in_array($item, $exceptions)) { $from = Folder::addPathElement($fromDir, $item); - if (is_file($from)) { + if (is_file($from) && (!is_file($to) || $options['scheme'] != Folder::SKIP)) { if (copy($from, $to)) { chmod($to, intval($mode, 8)); touch($to, filemtime($from)); From 1959b97ba3834cc413c9497ad3e9f3a4adeeb2e0 Mon Sep 17 00:00:00 2001 From: ptica Date: Mon, 8 Sep 2014 11:57:01 +0200 Subject: [PATCH 02/13] hardcode a relative path to core installed via composer as book suggests --- lib/Cake/Console/Command/Task/ProjectTask.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index c3345ffa7..4763b2876 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -340,6 +340,11 @@ class ProjectTask extends AppShell { $root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " DS . '" : "'"; $corePath = $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'"; + $composer = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; + if (file_exists($composer)) { + $corePath = " ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'"; + } + $result = str_replace('__CAKE_PATH__', $corePath, $contents, $count); if ($hardCode) { $result = str_replace('//define(\'CAKE_CORE', 'define(\'CAKE_CORE', $result); From 80788c3c007578a35857527dc6428c47b7902c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Tue, 9 Sep 2014 23:03:11 +0200 Subject: [PATCH 03/13] Removed use of @version annotation --- lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php | 1 - .../TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php | 1 - .../TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php | 1 - .../Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php | 1 - .../Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php | 1 - 5 files changed, 5 deletions(-) diff --git a/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php b/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php index b1de6381d..787e1b2a9 100644 --- a/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php +++ b/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php @@ -15,7 +15,6 @@ * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests * @package Cake.Test.Fixture * @since CakePHP(tm) v 1.2.0.5669 - * @version $Revision$ * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php index ffda73b66..17c8705f6 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php @@ -15,7 +15,6 @@ * @link http://cakephp.org CakePHP(tm) Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model.Behavior * @since CakePHP(tm) v 1.2.0.5669 - * @version $Revision$ * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php index d342c477c..f2d99d925 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php @@ -15,7 +15,6 @@ * @link http://cakephp.org CakePHP(tm) Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model.Behavior * @since CakePHP(tm) v 1.2.0.5669 - * @version $Revision$ * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php index 5ea7ee3a2..d5d0e3c81 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php @@ -13,7 +13,6 @@ * @link http://cakefoundation.org/projects/info/cakephp CakePHP Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model * @since CakePHP v 1.2.0.7726 - * @version $Revision$ * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php index b49d0c405..416d9f3f4 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php @@ -13,7 +13,6 @@ * @link http://cakefoundation.org/projects/info/cakephp CakePHP Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model * @since CakePHP v 1.2.0.7726 - * @version $Revision$ * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License From 9812147779eecdc463316caa10c99f86c0d41913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Tue, 9 Sep 2014 23:03:43 +0200 Subject: [PATCH 04/13] Removed use of @modifiedby annotation --- lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php | 1 - .../TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php | 1 - .../TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php | 1 - .../Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php | 1 - .../Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php | 1 - 5 files changed, 5 deletions(-) diff --git a/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php b/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php index 787e1b2a9..bde5ccaef 100644 --- a/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php +++ b/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php @@ -15,7 +15,6 @@ * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests * @package Cake.Test.Fixture * @since CakePHP(tm) v 1.2.0.5669 - * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php index 17c8705f6..f367b7a0b 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php @@ -15,7 +15,6 @@ * @link http://cakephp.org CakePHP(tm) Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model.Behavior * @since CakePHP(tm) v 1.2.0.5669 - * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php index f2d99d925..afde0dd11 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php @@ -15,7 +15,6 @@ * @link http://cakephp.org CakePHP(tm) Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model.Behavior * @since CakePHP(tm) v 1.2.0.5669 - * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php index d5d0e3c81..0f1abbe45 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php @@ -13,7 +13,6 @@ * @link http://cakefoundation.org/projects/info/cakephp CakePHP Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model * @since CakePHP v 1.2.0.7726 - * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php index 416d9f3f4..82669ba36 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php @@ -13,7 +13,6 @@ * @link http://cakefoundation.org/projects/info/cakephp CakePHP Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model * @since CakePHP v 1.2.0.7726 - * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ From 6cac5d0af3d308da07a9382cb898b5cec35ef3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Tue, 9 Sep 2014 23:04:29 +0200 Subject: [PATCH 05/13] Removed use of @lastmodified annotation --- lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php | 1 - .../TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php | 1 - .../TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php | 1 - .../Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php | 1 - .../Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php | 1 - 5 files changed, 5 deletions(-) diff --git a/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php b/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php index bde5ccaef..9787ac85c 100644 --- a/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php +++ b/lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php @@ -15,7 +15,6 @@ * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests * @package Cake.Test.Fixture * @since CakePHP(tm) v 1.2.0.5669 - * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ /** diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php index f367b7a0b..4d2f2a6e6 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php @@ -15,7 +15,6 @@ * @link http://cakephp.org CakePHP(tm) Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model.Behavior * @since CakePHP(tm) v 1.2.0.5669 - * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php index afde0dd11..2143cc7c1 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php @@ -15,7 +15,6 @@ * @link http://cakephp.org CakePHP(tm) Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model.Behavior * @since CakePHP(tm) v 1.2.0.5669 - * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php index 0f1abbe45..d1c32b8d6 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php @@ -13,7 +13,6 @@ * @link http://cakefoundation.org/projects/info/cakephp CakePHP Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model * @since CakePHP v 1.2.0.7726 - * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php index 82669ba36..69f83bd9a 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php @@ -13,7 +13,6 @@ * @link http://cakefoundation.org/projects/info/cakephp CakePHP Project * @package Cake.Test.TestApp.Plugin.TestPlugin.Model * @since CakePHP v 1.2.0.7726 - * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ From 86bc7f186194bb1da3b84873987fb4be0071b85f Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 9 Sep 2014 21:33:14 -0400 Subject: [PATCH 06/13] Add tests for #4521 and reformat code. Add a regression test for #4521 as the original author didn't have one. Reformat a long line since I was nearby already. Closes #4521 --- lib/Cake/Test/Case/Utility/FolderTest.php | 22 ++++++++++++++++++++++ lib/Cake/Utility/Folder.php | 8 +++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index c1f0e6cb8..fe1728da5 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -973,6 +973,28 @@ class FolderTest extends CakeTestCase { $Folder->delete(); } +/** + * Test that SKIP mode skips files too. + * + * @return void + */ + public function testCopyWithSkipFileSkipped() { + $path = TMP . 'folder_test'; + $folderOne = $path . DS . 'folder1'; + $folderTwo = $path . DS . 'folder2'; + + new Folder($path, true); + new Folder($folderOne, true); + new Folder($folderTwo, true); + file_put_contents($folderOne . DS . 'fileA.txt', 'Folder One File'); + file_put_contents($folderTwo . DS . 'fileA.txt', 'Folder Two File'); + + $Folder = new Folder($folderOne); + $result = $Folder->copy(array('to' => $folderTwo, 'scheme' => Folder::SKIP)); + $this->assertTrue($result); + $this->assertEquals('Folder Two File', file_get_contents($folderTwo . DS . 'fileA.txt')); + } + /** * testCopyWithOverwrite * diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index 7d768dff4..43337d4a4 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -645,7 +645,13 @@ class Folder { $to = $options; $options = array(); } - $options += array('to' => $to, 'from' => $this->path, 'mode' => $this->mode, 'skip' => array(), 'scheme' => Folder::MERGE); + $options += array( + 'to' => $to, + 'from' => $this->path, + 'mode' => $this->mode, + 'skip' => array(), + 'scheme' => Folder::MERGE + ); $fromDir = $options['from']; $toDir = $options['to']; From e77f96d8b731f7b70ac85158371ce57633e2f0b7 Mon Sep 17 00:00:00 2001 From: euromark Date: Wed, 10 Sep 2014 15:52:57 +0200 Subject: [PATCH 07/13] Use (int) cast instead of intval() function for performance reasons and to unify it. --- lib/Cake/Console/Command/Task/ControllerTask.php | 6 +++--- lib/Cake/Console/Command/Task/ExtractTask.php | 2 +- lib/Cake/Console/Command/Task/ModelTask.php | 10 +++++----- lib/Cake/Console/Command/Task/PluginTask.php | 2 +- lib/Cake/Controller/Component/CookieComponent.php | 2 +- lib/Cake/Controller/Component/PaginatorComponent.php | 2 +- lib/Cake/Model/Datasource/Database/Postgres.php | 2 +- lib/Cake/Model/Datasource/DboSource.php | 8 ++++---- lib/Cake/Test/Case/Utility/DebuggerTest.php | 4 ++-- lib/Cake/Utility/CakeTime.php | 2 +- lib/Cake/Utility/Hash.php | 4 ++-- lib/Cake/Utility/Set.php | 6 +++--- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index da0508e68..728358d66 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -452,14 +452,14 @@ class ControllerTask extends BakeTask { return $this->_stop(); } - if (!$enteredController || intval($enteredController) > count($controllers)) { + if (!$enteredController || (int)$enteredController > count($controllers)) { $this->err(__d('cake_console', "The Controller name you supplied was empty,\nor the number you selected was not an option. Please try again.")); $enteredController = ''; } } - if (intval($enteredController) > 0 && intval($enteredController) <= count($controllers)) { - $controllerName = $controllers[intval($enteredController) - 1]; + if ((int)$enteredController > 0 && (int)$enteredController <= count($controllers)) { + $controllerName = $controllers[(int)$enteredController - 1]; } else { $controllerName = Inflector::camelize($enteredController); } diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index d616839cd..be2d0f145 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -417,7 +417,7 @@ class ExtractTask extends AppShell { if ($mapCount === count($strings)) { extract(array_combine($map, $strings)); $category = isset($category) ? $category : 6; - $category = intval($category); + $category = (int)$category; $categoryName = $categories[$category]; $domain = isset($domain) ? $domain : 'default'; $details = array( diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 4b100c94f..878fcded9 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -176,7 +176,7 @@ class ModelTask extends BakeTask { $prompt = __d('cake_console', 'Make a selection from the choices above'); } $choice = $this->in($prompt, null, $default); - if (intval($choice) > 0 && intval($choice) <= $max) { + if ((int)$choice > 0 && (int)$choice <= $max) { $valid = true; } } @@ -765,7 +765,7 @@ class ModelTask extends BakeTask { if (!empty($showKeys)) { $this->out(__d('cake_console', 'A helpful List of possible keys')); $foreignKey = $this->inOptions($showKeys, __d('cake_console', 'What is the foreignKey?')); - $foreignKey = $showKeys[intval($foreignKey)]; + $foreignKey = $showKeys[(int)$foreignKey]; } if (!isset($foreignKey)) { $foreignKey = $this->in(__d('cake_console', 'What is the foreignKey? Specify your own.'), null, $suggestedForeignKey); @@ -985,14 +985,14 @@ class ModelTask extends BakeTask { return $this->_stop(); } - if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) { + if (!$enteredModel || (int)$enteredModel > count($this->_modelNames)) { $this->err(__d('cake_console', "The model name you supplied was empty,\n" . "or the number you selected was not an option. Please try again.")); $enteredModel = ''; } } - if (intval($enteredModel) > 0 && intval($enteredModel) <= count($this->_modelNames)) { - return $this->_modelNames[intval($enteredModel) - 1]; + if ((int)$enteredModel > 0 && (int)$enteredModel <= count($this->_modelNames)) { + return $this->_modelNames[(int)$enteredModel - 1]; } return $enteredModel; diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index f3bcf8dde..b92d10662 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -203,7 +203,7 @@ class PluginTask extends AppShell { } $prompt = __d('cake_console', 'Choose a plugin path from the paths above.'); $choice = $this->in($prompt, null, 1); - if (intval($choice) > 0 && intval($choice) <= $max) { + if ((int)$choice > 0 && (int)$choice <= $max) { $valid = true; } } diff --git a/lib/Cake/Controller/Component/CookieComponent.php b/lib/Cake/Controller/Component/CookieComponent.php index 55a031523..fb5e4c38c 100644 --- a/lib/Cake/Controller/Component/CookieComponent.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -414,7 +414,7 @@ class CookieComponent extends Component { $now = new DateTime(); if (is_int($expires) || is_numeric($expires)) { - return $this->_expires = $now->format('U') + intval($expires); + return $this->_expires = $now->format('U') + (int)$expires; } $now->modify($expires); return $this->_expires = $now->format('U'); diff --git a/lib/Cake/Controller/Component/PaginatorComponent.php b/lib/Cake/Controller/Component/PaginatorComponent.php index 53144ec6f..960484b40 100644 --- a/lib/Cake/Controller/Component/PaginatorComponent.php +++ b/lib/Cake/Controller/Component/PaginatorComponent.php @@ -179,7 +179,7 @@ class PaginatorComponent extends Component { $extra['type'] = $type; } - if (intval($page) < 1) { + if ((int)$page < 1) { $page = 1; } $page = $options['page'] = (int)$page; diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index a9225349d..b9c8524fd 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -726,7 +726,7 @@ class Postgres extends DboSource { return 36; } if ($limit) { - return intval($limit); + return (int)$limit; } return null; } diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index b005a41bf..3505a49d6 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -3048,7 +3048,7 @@ class DboSource extends DataSource { list($col, $limit) = explode('(', $col); } if ($limit !== null) { - return intval($limit); + return (int)$limit; } return null; } @@ -3089,7 +3089,7 @@ class DboSource extends DataSource { } } } - return intval($length); + return (int)$length; } /** @@ -3456,10 +3456,10 @@ class DboSource extends DataSource { if (is_bool($value)) { return 'boolean'; } - if (is_float($value) && floatval($value) === $value) { + if (is_float($value) && (float)$value === $value) { return 'float'; } - if (is_int($value) && intval($value) === $value) { + if (is_int($value) && (int)$value === $value) { return 'integer'; } if (is_string($value) && strlen($value) > 255) { diff --git a/lib/Cake/Test/Case/Utility/DebuggerTest.php b/lib/Cake/Test/Case/Utility/DebuggerTest.php index 0379e4f4d..e967e7776 100644 --- a/lib/Cake/Test/Case/Utility/DebuggerTest.php +++ b/lib/Cake/Test/Case/Utility/DebuggerTest.php @@ -187,7 +187,7 @@ class DebuggerTest extends CakeTestCase { 'error' => array(), 'code' => array(), '8', '/code', 'file' => array(), 'preg:/[^<]+/', '/file', - 'line' => array(), '' . (intval(__LINE__) - 7), '/line', + 'line' => array(), '' . ((int)__LINE__ - 7), '/line', 'preg:/Undefined variable:\s+foo/', '/error' ); @@ -246,7 +246,7 @@ class DebuggerTest extends CakeTestCase { 'getTimezone()->getName() != date_default_timezone_get() diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index d24998de5..c6a8c06b2 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -290,8 +290,8 @@ class Hash { $count = count($path); $last = $count - 1; foreach ($path as $i => $key) { - if (is_numeric($key) && intval($key) > 0 || $key === '0') { - $key = intval($key); + if (is_numeric($key) && (int)$key > 0 || $key === '0') { + $key = (int)$key; } if ($op === 'insert') { if ($i === $last) { diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index df1b6e804..122160745 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -560,7 +560,7 @@ class Set { } foreach ($path as $i => $key) { - if (is_numeric($key) && intval($key) > 0 || $key === '0') { + if (is_numeric($key) && (int)$key > 0 || $key === '0') { if (isset($data[$key])) { $data = $data[$key]; } else { @@ -657,8 +657,8 @@ class Set { } foreach ($path as $i => $key) { - if (is_numeric($key) && intval($key) > 0 || $key === '0') { - $key = intval($key); + if (is_numeric($key) && (int)$key > 0 || $key === '0') { + $key = (int)$key; } if ($i === count($path) - 1) { return (is_array($data) && array_key_exists($key, $data)); From 04ef39217f2edb0a4abee6c903146036f3c53a91 Mon Sep 17 00:00:00 2001 From: euromark Date: Wed, 10 Sep 2014 16:29:23 +0200 Subject: [PATCH 08/13] Take care of more int casts. --- lib/Cake/Cache/Engine/ApcEngine.php | 2 +- lib/Cake/Cache/Engine/FileEngine.php | 2 +- lib/Cake/Cache/Engine/WincacheEngine.php | 2 +- lib/Cake/Cache/Engine/XcacheEngine.php | 2 +- lib/Cake/Console/Command/AclShell.php | 4 ++-- lib/Cake/Console/Command/Task/ModelTask.php | 2 +- lib/Cake/Controller/Component/PaginatorComponent.php | 2 +- lib/Cake/Model/Datasource/Database/Sqlite.php | 2 +- lib/Cake/Model/Datasource/Database/Sqlserver.php | 6 +++--- lib/Cake/Model/Model.php | 8 ++++---- lib/Cake/Test/Case/Model/ModelWriteTest.php | 2 +- lib/Cake/Utility/CakeTime.php | 12 ++++++------ lib/Cake/View/Helper/FormHelper.php | 2 +- lib/Cake/View/Helper/JsHelper.php | 4 ++-- lib/Cake/View/Helper/PaginatorHelper.php | 2 +- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/Cake/Cache/Engine/ApcEngine.php b/lib/Cake/Cache/Engine/ApcEngine.php index 37548f33e..c2f0acfe1 100644 --- a/lib/Cake/Cache/Engine/ApcEngine.php +++ b/lib/Cake/Cache/Engine/ApcEngine.php @@ -75,7 +75,7 @@ class ApcEngine extends CacheEngine { */ public function read($key) { $time = time(); - $cachetime = intval(apc_fetch($key . '_expires')); + $cachetime = (int)apc_fetch($key . '_expires'); if ($cachetime !== 0 && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) { return false; } diff --git a/lib/Cake/Cache/Engine/FileEngine.php b/lib/Cake/Cache/Engine/FileEngine.php index 904dc0d2b..434191558 100644 --- a/lib/Cake/Cache/Engine/FileEngine.php +++ b/lib/Cake/Cache/Engine/FileEngine.php @@ -165,7 +165,7 @@ class FileEngine extends CacheEngine { $this->_File->rewind(); $time = time(); - $cachetime = intval($this->_File->current()); + $cachetime = (int)$this->_File->current(); if ($cachetime !== false && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) { if ($this->settings['lock']) { diff --git a/lib/Cake/Cache/Engine/WincacheEngine.php b/lib/Cake/Cache/Engine/WincacheEngine.php index df684f0bc..392955718 100644 --- a/lib/Cake/Cache/Engine/WincacheEngine.php +++ b/lib/Cake/Cache/Engine/WincacheEngine.php @@ -80,7 +80,7 @@ class WincacheEngine extends CacheEngine { */ public function read($key) { $time = time(); - $cachetime = intval(wincache_ucache_get($key . '_expires')); + $cachetime = (int)wincache_ucache_get($key . '_expires'); if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) { return false; } diff --git a/lib/Cake/Cache/Engine/XcacheEngine.php b/lib/Cake/Cache/Engine/XcacheEngine.php index afa1613ba..9c1855605 100644 --- a/lib/Cake/Cache/Engine/XcacheEngine.php +++ b/lib/Cake/Cache/Engine/XcacheEngine.php @@ -80,7 +80,7 @@ class XcacheEngine extends CacheEngine { public function read($key) { if (xcache_isset($key)) { $time = time(); - $cachetime = intval(xcache_get($key . '_expires')); + $cachetime = (int)xcache_get($key . '_expires'); if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) { return false; } diff --git a/lib/Cake/Console/Command/AclShell.php b/lib/Cake/Console/Command/AclShell.php index 622bc20ce..f5e493f7a 100644 --- a/lib/Cake/Console/Command/AclShell.php +++ b/lib/Cake/Console/Command/AclShell.php @@ -579,8 +579,8 @@ class AclShell extends AppShell { * @return array aro, aco, action */ protected function _getParams() { - $aro = is_numeric($this->args[0]) ? intval($this->args[0]) : $this->args[0]; - $aco = is_numeric($this->args[1]) ? intval($this->args[1]) : $this->args[1]; + $aro = is_numeric($this->args[0]) ? (int)$this->args[0] : $this->args[0]; + $aco = is_numeric($this->args[1]) ? (int)$this->args[1] : $this->args[1]; $aroName = $aro; $acoName = $aco; diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 878fcded9..3b6282739 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -728,7 +728,7 @@ class ModelTask extends BakeTask { while (strtolower($wannaDoMoreAssoc) === 'y') { $assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); $this->out(__d('cake_console', 'What is the association type?')); - $assocType = intval($this->inOptions($assocs, __d('cake_console', 'Enter a number'))); + $assocType = (int)$this->inOptions($assocs, __d('cake_console', 'Enter a number')); $this->out(__d('cake_console', "For the following options be very careful to match your setup exactly.\n" . "Any spelling mistakes will cause errors.")); diff --git a/lib/Cake/Controller/Component/PaginatorComponent.php b/lib/Cake/Controller/Component/PaginatorComponent.php index 960484b40..82a322fec 100644 --- a/lib/Cake/Controller/Component/PaginatorComponent.php +++ b/lib/Cake/Controller/Component/PaginatorComponent.php @@ -211,7 +211,7 @@ class PaginatorComponent extends Component { } $count = $object->find('count', array_merge($parameters, $extra)); } - $pageCount = intval(ceil($count / $limit)); + $pageCount = (int)ceil($count / $limit); $requestedPage = $page; $page = max(min($page, $pageCount), 1); diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index b33f4d0f2..5e141a757 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -509,7 +509,7 @@ class Sqlite extends DboSource { $key['name'] = 'PRIMARY'; } $index[$key['name']]['column'] = $keyCol[0]['name']; - $index[$key['name']]['unique'] = intval($key['unique'] == 1); + $index[$key['name']]['unique'] = (int)$key['unique'] === 1; } else { if (!is_array($index[$key['name']]['column'])) { $col[] = $index[$key['name']]['column']; diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index 2d71b512a..393184460 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -537,9 +537,9 @@ class Sqlserver extends DboSource { if (version_compare($this->getVersion(), '11', '<') && preg_match('/FETCH\sFIRST\s+([0-9]+)/i', $limit, $offset)) { preg_match('/OFFSET\s*(\d+)\s*.*?(\d+)\s*ROWS/', $limit, $limitOffset); - $limit = 'TOP ' . intval($limitOffset[2]); - $page = intval($limitOffset[1] / $limitOffset[2]); - $offset = intval($limitOffset[2] * $page); + $limit = 'TOP ' . (int)$limitOffset[2]; + $page = (int)($limitOffset[1] / $limitOffset[2]); + $offset = (int)($limitOffset[2] * $page); $rowCounter = self::ROW_COUNTER; $sql = "SELECT {$limit} * FROM ( diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index a33b4a888..bb4a44ce1 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2094,7 +2094,7 @@ class Model extends Object implements CakeEventListener { if (isset($keys['old'][$foreignKey]) && $keys['old'][$foreignKey] != $keys[$foreignKey]) { $conditions[$fkQuoted] = $keys['old'][$foreignKey]; - $count = intval($this->find('count', compact('conditions', 'recursive'))); + $count = (int)$this->find('count', compact('conditions', 'recursive')); $Model->updateAll( array($field => $count), @@ -2108,7 +2108,7 @@ class Model extends Object implements CakeEventListener { $conditions = array_merge($conditions, (array)$conditions); } - $count = intval($this->find('count', compact('conditions', 'recursive'))); + $count = (int)$this->find('count', compact('conditions', 'recursive')); $Model->updateAll( array($field => $count), @@ -2979,7 +2979,7 @@ class Model extends Object implements CakeEventListener { $query = $this->{'_find' . ucfirst($type)}('before', $query); } - if (!is_numeric($query['page']) || intval($query['page']) < 1) { + if (!is_numeric($query['page']) || (int)$query['page'] < 1) { $query['page'] = 1; } @@ -3092,7 +3092,7 @@ class Model extends Object implements CakeEventListener { return count($results); } - return intval($results[0][$key]['count']); + return (int)$results[0][$key]['count']; } } diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index cf125c76d..0cecb0156 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -2528,7 +2528,7 @@ class ModelWriteTest extends BaseModelTest { 'user' => 'some user', 'password' => 'some password' ))); - $this->assertTrue(is_int($TestModel->id) || (intval($TestModel->id) === 5)); + $this->assertTrue(is_int($TestModel->id) || ((int)$TestModel->id === 5)); $id = $TestModel->id; $TestModel->save(array( diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index 8b995feca..47ca44fe5 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -994,12 +994,12 @@ class CakeTime { $time = self::fromString($dateString); } return gmmktime( - intval(date('G', $time)), - intval(date('i', $time)), - intval(date('s', $time)), - intval(date('n', $time)), - intval(date('j', $time)), - intval(date('Y', $time)) + (int)date('G', $time), + (int)date('i', $time), + (int)date('s', $time), + (int)date('n', $time), + (int)date('j', $time), + (int)date('Y', $time) ); } diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 7cbe69a88..815516ba9 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2893,7 +2893,7 @@ class FormHelper extends AppHelper { } break; case 'year': - $current = intval(date('Y')); + $current = (int)date('Y'); $min = !isset($options['min']) ? $current - 20 : (int)$options['min']; $max = !isset($options['max']) ? $current + 20 : (int)$options['max']; diff --git a/lib/Cake/View/Helper/JsHelper.php b/lib/Cake/View/Helper/JsHelper.php index b3fe28103..e534b28ca 100644 --- a/lib/Cake/View/Helper/JsHelper.php +++ b/lib/Cake/View/Helper/JsHelper.php @@ -292,7 +292,7 @@ class JsHelper extends AppHelper { */ public function link($title, $url = null, $options = array()) { if (!isset($options['id'])) { - $options['id'] = 'link-' . intval(mt_rand()); + $options['id'] = 'link-' . (int)mt_rand(); } list($options, $htmlOptions) = $this->_getHtmlOptions($options); $out = $this->Html->link($title, $url, $htmlOptions); @@ -368,7 +368,7 @@ class JsHelper extends AppHelper { */ public function submit($caption = null, $options = array()) { if (!isset($options['id'])) { - $options['id'] = 'submit-' . intval(mt_rand()); + $options['id'] = 'submit-' . (int)mt_rand(); } $formOptions = array('div'); list($options, $htmlOptions) = $this->_getHtmlOptions($options, $formOptions); diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index aeedb5730..ccbcc4794 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -740,7 +740,7 @@ class PaginatorHelper extends AppHelper { $out = ''; if ($modulus && $params['pageCount'] > $modulus) { - $half = intval($modulus / 2); + $half = (int)($modulus / 2); $end = $params['page'] + $half; if ($end > $params['pageCount']) { From e3dc51bb685b6f3c9623d5fae7a4441f6b85d729 Mon Sep 17 00:00:00 2001 From: euromark Date: Wed, 10 Sep 2014 16:40:22 +0200 Subject: [PATCH 09/13] Manually correct remaining casts. --- lib/Cake/Model/Datasource/Database/Mysql.php | 2 +- lib/Cake/Model/Datasource/Database/Postgres.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 399b2f61b..e931d6718 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -493,7 +493,7 @@ class Mysql extends DboSource { if ($idx->Index_type === 'FULLTEXT') { $index[$idx->Key_name]['type'] = strtolower($idx->Index_type); } else { - $index[$idx->Key_name]['unique'] = intval($idx->Non_unique == 0); + $index[$idx->Key_name]['unique'] = (int)($idx->Non_unique == 0); } } else { if (!empty($index[$idx->Key_name]['column']) && !is_array($index[$idx->Key_name]['column'])) { diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index b9c8524fd..1c0a6c223 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -219,10 +219,10 @@ class Postgres extends DboSource { } elseif ($c->type === 'uuid') { $length = 36; } else { - $length = intval($c->oct_length); + $length = (int)$c->oct_length; } } elseif (!empty($c->char_length)) { - $length = intval($c->char_length); + $length = (int)$c->char_length; } else { $length = $this->length($c->type); } From 3e25282d4c3f9940a7c9939bd189b89340c9d181 Mon Sep 17 00:00:00 2001 From: euromark Date: Wed, 10 Sep 2014 17:40:01 +0200 Subject: [PATCH 10/13] Fix PHP flaw around intval with custom base. --- lib/Cake/Utility/Folder.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index 43337d4a4..004e02827 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -382,7 +382,7 @@ class Folder { if ($recursive === false && is_dir($path)) { //@codingStandardsIgnoreStart - if (@chmod($path, intval($mode, 8))) { + if (@chmod($path, intval((string)$mode, 8))) { //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s changed to %s', $path, $mode); return true; @@ -405,7 +405,7 @@ class Folder { } //@codingStandardsIgnoreStart - if (@chmod($fullpath, intval($mode, 8))) { + if (@chmod($fullpath, intval((string)$mode, 8))) { //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s changed to %s', $fullpath, $mode); } else { @@ -681,7 +681,7 @@ class Folder { $from = Folder::addPathElement($fromDir, $item); if (is_file($from) && (!is_file($to) || $options['scheme'] != Folder::SKIP)) { if (copy($from, $to)) { - chmod($to, intval($mode, 8)); + chmod($to, intval((string)$mode, 8)); touch($to, filemtime($from)); $this->_messages[] = __d('cake_dev', '%s copied to %s', $from, $to); } else { From eedefb9dec3564ef466b4ddedad573a895ebe590 Mon Sep 17 00:00:00 2001 From: euromark Date: Wed, 10 Sep 2014 17:56:02 +0200 Subject: [PATCH 11/13] Clarify octal input instead. --- lib/Cake/Utility/Folder.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index 004e02827..cd081e29d 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -368,11 +368,11 @@ class Folder { /** * Change the mode on a directory structure recursively. This includes changing the mode on files as well. * - * @param string $path The path to chmod - * @param int $mode octal value 0755 - * @param bool $recursive chmod recursively, set to false to only change the current directory. - * @param array $exceptions array of files, directories to skip - * @return bool Returns TRUE on success, FALSE on failure + * @param string $path The path to chmod. + * @param int $mode Octal value, e.g. 0755. + * @param bool $recursive Chmod recursively, set to false to only change the current directory. + * @param array $exceptions Array of files, directories to skip. + * @return bool Success. * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::chmod */ public function chmod($path, $mode = false, $recursive = true, $exceptions = array()) { @@ -382,7 +382,7 @@ class Folder { if ($recursive === false && is_dir($path)) { //@codingStandardsIgnoreStart - if (@chmod($path, intval((string)$mode, 8))) { + if (@chmod($path, intval($mode, 8))) { //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s changed to %s', $path, $mode); return true; @@ -405,7 +405,7 @@ class Folder { } //@codingStandardsIgnoreStart - if (@chmod($fullpath, intval((string)$mode, 8))) { + if (@chmod($fullpath, intval($mode, 8))) { //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s changed to %s', $fullpath, $mode); } else { @@ -628,12 +628,12 @@ class Folder { * * - `to` The directory to copy to. * - `from` The directory to copy from, this will cause a cd() to occur, changing the results of pwd(). - * - `mode` The mode to copy the files/directories with. + * - `mode` The mode to copy the files/directories with, e.g. 0775. * - `skip` Files/directories to skip. * - `scheme` Folder::MERGE, Folder::OVERWRITE, Folder::SKIP * * @param array|string $options Either an array of options (see above) or a string of the destination directory. - * @return bool Success + * @return bool Success. * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::copy */ public function copy($options) { @@ -681,7 +681,7 @@ class Folder { $from = Folder::addPathElement($fromDir, $item); if (is_file($from) && (!is_file($to) || $options['scheme'] != Folder::SKIP)) { if (copy($from, $to)) { - chmod($to, intval((string)$mode, 8)); + chmod($to, intval($mode, 8)); touch($to, filemtime($from)); $this->_messages[] = __d('cake_dev', '%s copied to %s', $from, $to); } else { From a6df3300b95bab6cf9a0e218cd60bf00f260b4a0 Mon Sep 17 00:00:00 2001 From: euromark Date: Wed, 10 Sep 2014 17:57:26 +0200 Subject: [PATCH 12/13] Wording. --- lib/Cake/Utility/Folder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index cd081e29d..f84f0a39a 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -628,7 +628,7 @@ class Folder { * * - `to` The directory to copy to. * - `from` The directory to copy from, this will cause a cd() to occur, changing the results of pwd(). - * - `mode` The mode to copy the files/directories with, e.g. 0775. + * - `mode` The mode to copy the files/directories with as integer, e.g. 0775. * - `skip` Files/directories to skip. * - `scheme` Folder::MERGE, Folder::OVERWRITE, Folder::SKIP * From 90ad813b40fc6c0f2f844dc65ec851f6b1a73063 Mon Sep 17 00:00:00 2001 From: Yves Date: Wed, 10 Sep 2014 22:47:25 +0200 Subject: [PATCH 13/13] Fix Hash not returning correct value with special paths When doing a Hash::insert() with a part of the path starting with a '0', Hash::get() returned null even if the same path was used. --- lib/Cake/Test/Case/Utility/HashTest.php | 7 +++++++ lib/Cake/Utility/Hash.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 96476315a..dfc3c59c8 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -1367,6 +1367,13 @@ class HashTest extends CakeTestCase { 'pages' => array('name' => array()), ); $this->assertEquals($expected, $result); + + $a = array( + 'foo' => array('bar' => 'baz') + ); + $result = Hash::insert($a, 'some.0123.path', array('foo' => array('bar' => 'baz'))); + $expected = array('foo' => array('bar' => 'baz')); + $this->assertEquals($expected, Hash::get($result, 'some.0123.path')); } /** diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index c6a8c06b2..f88365b74 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -290,7 +290,7 @@ class Hash { $count = count($path); $last = $count - 1; foreach ($path as $i => $key) { - if (is_numeric($key) && (int)$key > 0 || $key === '0') { + if ((is_numeric($key) && intval($key) > 0 || $key === '0') && strpos($key, '0') !== 0) { $key = (int)$key; } if ($op === 'insert') {