Browse Source

Merge branch '2.6' into 3.0

Conflicts:
	lib/Cake/Console/Command/AclShell.php
	lib/Cake/Console/Command/Task/ControllerTask.php
	lib/Cake/Console/Command/Task/ModelTask.php
	lib/Cake/Console/Command/Task/PluginTask.php
	lib/Cake/Console/Command/Task/ProjectTask.php
	lib/Cake/Controller/Component/CookieComponent.php
	lib/Cake/Controller/Component/PaginatorComponent.php
	lib/Cake/Model/Datasource/Database/Mysql.php
	lib/Cake/Model/Datasource/Database/Postgres.php
	lib/Cake/Model/Datasource/Database/Sqlite.php
	lib/Cake/Model/Datasource/Database/Sqlserver.php
	lib/Cake/Model/Datasource/DboSource.php
	lib/Cake/Model/Model.php
	lib/Cake/Test/Case/Model/ModelWriteTest.php
	lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php
	lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php
	lib/Cake/Utility/CakeTime.php
	lib/Cake/Utility/Set.php
	lib/Cake/View/Helper/FormHelper.php
	lib/Cake/View/Helper/JsHelper.php
	lib/Cake/View/Helper/PaginatorHelper.php
	src/Cache/Engine/ApcEngine.php
	src/Cache/Engine/WincacheEngine.php
	src/Cache/Engine/XcacheEngine.php
	src/Shell/Task/ExtractTask.php
	src/Utility/Hash.php
	tests/Fixture/TranslateWithPrefixFixture.php
	tests/TestCase/Error/DebuggerTest.php
	tests/test_app/Plugin/Company/TestPluginThree/src/Model/Table/TestPluginThreeCommentsTable.php
	tests/test_app/TestApp/Model/Behavior/SluggableBehavior.php
ADmad 11 years ago
parent
commit
6e53f3fc58

+ 2 - 1
src/Cache/Engine/ApcEngine.php

@@ -71,7 +71,8 @@ class ApcEngine extends CacheEngine {
  * Read a key from the cache
  *
  * @param string $key Identifier for the data
- * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
+ * @return mixed The cached data, or false if the data doesn't exist,
+ *   has expired, or if there was an error fetching it
  */
 	public function read($key) {
 		$key = $this->_key($key);

+ 2 - 2
src/Cache/Engine/WincacheEngine.php

@@ -73,8 +73,8 @@ class WincacheEngine extends CacheEngine {
  * Read a key from the cache
  *
  * @param string $key Identifier for the data
- * @return mixed The cached data, or false if the data doesn't exist, has expired, or if
- *     there was an error fetching it
+ * @return mixed The cached data, or false if the data doesn't exist,
+ *   has expired, or if there was an error fetching it
  */
 	public function read($key) {
 		$key = $this->_key($key);

+ 2 - 1
src/Cache/Engine/XcacheEngine.php

@@ -87,7 +87,8 @@ class XcacheEngine extends CacheEngine {
  * Read a key from the cache
  *
  * @param string $key Identifier for the data
- * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
+ * @return mixed The cached data, or false if the data doesn't exist,
+ *   has expired, or if there was an error fetching it
  */
 	public function read($key) {
 		$key = $this->_key($key);

+ 15 - 9
src/Filesystem/Folder.php

@@ -389,11 +389,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, array $exceptions = array()) {
@@ -649,12 +649,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 as integer, 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) {
@@ -666,7 +666,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'];
@@ -694,7 +700,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));

+ 3 - 1
src/Utility/Hash.php

@@ -316,7 +316,9 @@ 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) && (int)($key) > 0 || $key === '0') &&
+				strpos($key, '0') !== 0
+			) {
 				$key = (int)$key;
 			}
 			if ($op === 'insert') {

+ 2 - 2
tests/TestCase/Error/DebuggerTest.php

@@ -200,7 +200,7 @@ class DebuggerTest extends TestCase {
 			'error' => array(),
 			'code' => array(), '8', '/code',
 			'file' => array(), 'preg:/[^<]+/', '/file',
-			'line' => array(), '' . (int)__LINE__ - 7, '/line',
+			'line' => array(), '' . ((int)__LINE__ - 7), '/line',
 			'preg:/Undefined variable:\s+foo/',
 			'/error'
 		);
@@ -259,7 +259,7 @@ class DebuggerTest extends TestCase {
 			'<error',
 			'<code', '8', '/code',
 			'<file', 'preg:/[^<]+/', '/file',
-			'<line', '' . (int)__LINE__ - 7, '/line',
+			'<line', '' . ((int)__LINE__ - 7), '/line',
 			'preg:/Undefined variable:\s+foo/',
 			'/error'
 		);

+ 22 - 0
tests/TestCase/Filesystem/FolderTest.php

@@ -923,6 +923,28 @@ class FolderTest extends TestCase {
 	}
 
 /**
+ * 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
  *
  * Verify that subdirectories existing in both destination and source directory

+ 7 - 0
tests/TestCase/Utility/HashTest.php

@@ -1370,6 +1370,13 @@ class HashTest extends TestCase {
 			'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'));
 	}
 
 /**