Browse Source

Merge branch 'master' into 2.6

Conflicts:
	lib/Cake/VERSION.txt
mark_story 11 years ago
parent
commit
497ecd3f80

+ 8 - 4
app/Console/cake.php

@@ -17,20 +17,24 @@
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
 
-$ds = DIRECTORY_SEPARATOR;
-$dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php';
+if (!defined('DS')) {
+	define('DS', DIRECTORY_SEPARATOR);
+}
+
+$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php';
 
 if (function_exists('ini_set')) {
 	$root = dirname(dirname(dirname(__FILE__)));
 
 	// the following line differs from its sibling
 	// /lib/Cake/Console/Templates/skel/Console/cake.php
-	ini_set('include_path', $root . $ds . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
+	ini_set('include_path', $root . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
+	unset($root);
 }
 
 if (!include $dispatcher) {
 	trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
 }
-unset($paths, $path, $dispatcher, $root, $ds);
+unset($dispatcher);
 
 return ShellDispatcher::run($argv);

+ 0 - 1
lib/Cake/Console/ShellDispatcher.php

@@ -79,7 +79,6 @@ class ShellDispatcher {
 		}
 
 		if (!defined('CAKE_CORE_INCLUDE_PATH')) {
-			define('DS', DIRECTORY_SEPARATOR);
 			define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__))));
 			define('CAKEPHP_SHELL', true);
 			if (!defined('CORE_PATH')) {

+ 7 - 3
lib/Cake/Console/Templates/skel/Console/cake.php

@@ -16,8 +16,11 @@
  * @since         CakePHP(tm) v 2.0
  */
 
-$ds = DIRECTORY_SEPARATOR;
-$dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php';
+if (!defined('DS')) {
+	define('DS', DIRECTORY_SEPARATOR);
+}
+
+$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php';
 
 if (function_exists('ini_set')) {
 	$root = dirname(dirname(dirname(__FILE__)));
@@ -25,11 +28,12 @@ if (function_exists('ini_set')) {
 	// the following line differs from its sibling
 	// /app/Console/cake.php
 	ini_set('include_path', $root . PATH_SEPARATOR . __CAKE_PATH__ . PATH_SEPARATOR . ini_get('include_path'));
+	unset($root);
 }
 
 if (!include $dispatcher) {
 	trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
 }
-unset($paths, $path, $dispatcher, $root, $ds);
+unset($dispatcher);
 
 return ShellDispatcher::run($argv);

+ 12 - 7
lib/Cake/Console/cake.php

@@ -17,21 +17,24 @@
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
 
-$ds = DIRECTORY_SEPARATOR;
-$dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php';
+if (!defined('DS')) {
+	define('DS', DIRECTORY_SEPARATOR);
+}
+
+$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php';
 $found = false;
 $paths = explode(PATH_SEPARATOR, ini_get('include_path'));
 
 foreach ($paths as $path) {
-	if (file_exists($path . $ds . $dispatcher)) {
+	if (file_exists($path . DS . $dispatcher)) {
 		$found = $path;
 		break;
 	}
 }
 
 if (!$found) {
-	$rootInstall = dirname(dirname(dirname(__FILE__))) . $ds . $dispatcher;
-	$composerInstall = dirname(dirname(__FILE__)) . $ds . $dispatcher;
+	$rootInstall = dirname(dirname(dirname(__FILE__))) . DS . $dispatcher;
+	$composerInstall = dirname(dirname(__FILE__)) . DS . $dispatcher;
 
 	if (file_exists($composerInstall)) {
 		include $composerInstall;
@@ -40,10 +43,12 @@ if (!$found) {
 	} else {
 		trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
 	}
+	unset($rootInstall, $composerInstall);
+
 } else {
-	include $found . $ds . $dispatcher;
+	include $found . DS . $dispatcher;
 }
 
-unset($paths, $path, $found, $dispatcher, $root, $ds);
+unset($paths, $path, $found, $dispatcher);
 
 return ShellDispatcher::run($argv);

+ 3 - 3
lib/Cake/Controller/Component/Auth/BasicAuthenticate.php

@@ -41,9 +41,9 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
  * by this authentication provider which triggers the login dialog in the browser/client.
  *
  * You may also want to use `$this->Auth->unauthorizedRedirect = false;`.
- * By default unauthorized user is redirected to the referrer URL or
- * AuthComponent::$loginAction or '/'. If unauthorizedRedirect is set to false a
- * ForbiddenException exception is thrown instead of redirecting.
+ * By default, unauthorized users are redirected to the referrer URL,
+ * `AuthComponent::$loginAction`, or '/'. If unauthorizedRedirect is set to
+ * false, a ForbiddenException exception is thrown instead of redirecting.
  *
  * @package       Cake.Controller.Component.Auth
  * @since 2.0

+ 0 - 2
lib/Cake/Controller/Scaffold.php

@@ -18,8 +18,6 @@
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
 
-App::uses('Scaffold', 'View');
-
 /**
  * Scaffolding is a set of automatic actions for starting web development work faster.
  *

+ 9 - 0
lib/Cake/Test/Case/Utility/HashTest.php

@@ -868,10 +868,19 @@ class HashTest extends CakeTestCase {
 				'active' => false
 			),
 		);
+		$result = Hash::extract($users, '{n}[active=0]');
+		$this->assertCount(1, $result);
+		$this->assertEquals($users[2], $result[0]);
+
 		$result = Hash::extract($users, '{n}[active=false]');
 		$this->assertCount(1, $result);
 		$this->assertEquals($users[2], $result[0]);
 
+		$result = Hash::extract($users, '{n}[active=1]');
+		$this->assertCount(2, $result);
+		$this->assertEquals($users[0], $result[0]);
+		$this->assertEquals($users[1], $result[1]);
+
 		$result = Hash::extract($users, '{n}[active=true]');
 		$this->assertCount(2, $result);
 		$this->assertEquals($users[0], $result[0]);

+ 65 - 37
lib/Cake/Test/Case/View/Helper/TextHelperTest.php

@@ -363,54 +363,82 @@ class TextHelperTest extends CakeTestCase {
 	}
 
 /**
- * testAutoLinkEmails method
+ * Data provider for autoLinkEmail.
  *
  * @return void
  */
-	public function testAutoLinkEmails() {
-		$text = 'This is a test text';
-		$expected = 'This is a test text';
-		$result = $this->Text->autoLinkUrls($text);
-		$this->assertEquals($expected, $result);
+	public function autoLinkEmailProvider() {
+		return array(
+			array(
+				'This is a test text',
+				'This is a test text',
+			),
 
-		$text = 'email@example.com address';
-		$expected = '<a href="mailto:email@example.com">email@example.com</a> address';
-		$result = $this->Text->autoLinkEmails($text);
-		$this->assertEquals($expected, $result);
+			array(
+				'email@example.com address',
+				'<a href="mailto:email@example.com">email@example.com</a> address',
+			),
 
-		$text = 'email@example.com address';
-		$expected = '<a href="mailto:email@example.com">email@example.com</a> address';
-		$result = $this->Text->autoLinkEmails($text);
-		$this->assertEquals($expected, $result);
+			array(
+				'email@example.com address',
+				'<a href="mailto:email@example.com">email@example.com</a> address',
+			),
 
-		$text = '(email@example.com) address';
-		$expected = '(<a href="mailto:email@example.com">email@example.com</a>) address';
-		$result = $this->Text->autoLinkEmails($text);
-		$this->assertEquals($expected, $result);
+			array(
+				'(email@example.com) address',
+				'(<a href="mailto:email@example.com">email@example.com</a>) address',
+			),
 
-		$text = 'Text with email@example.com address';
-		$expected = 'Text with <a href="mailto:email@example.com">email@example.com</a> address';
-		$result = $this->Text->autoLinkEmails($text);
-		$this->assertEquals($expected, $result);
+			array(
+				'Text with email@example.com address',
+				'Text with <a href="mailto:email@example.com">email@example.com</a> address',
+			),
 
-		$text = "Text with o'hare._-bob@example.com address";
-		$expected = 'Text with <a href="mailto:o&#039;hare._-bob@example.com">o&#039;hare._-bob@example.com</a> address';
-		$result = $this->Text->autoLinkEmails($text);
-		$this->assertEquals($expected, $result);
+			array(
+				"Text with o'hare._-bob@example.com address",
+				'Text with <a href="mailto:o&#039;hare._-bob@example.com">o&#039;hare._-bob@example.com</a> address',
+			),
 
-		$text = 'Text with email@example.com address';
-		$expected = 'Text with <a href="mailto:email@example.com" class="link">email@example.com</a> address';
-		$result = $this->Text->autoLinkEmails($text, array('class' => 'link'));
-		$this->assertEquals($expected, $result);
+			array(
+				'Text with düsentrieb@küchenschöhn-not-working.de address',
+				'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address',
+			),
 
-		$text = 'Text with düsentrieb@küchenschöhn-not-working.de address';
-		$expected = 'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address';
-		$result = $this->Text->autoLinkEmails($text);
-		$this->assertEquals($expected, $result);
+			array(
+				'Text with me@subdomain.küchenschöhn.de address',
+				'Text with <a href="mailto:me@subdomain.küchenschöhn.de">me@subdomain.küchenschöhn.de</a> address',
+			),
+
+			array(
+				'Text with email@example.com address',
+				'Text with <a href="mailto:email@example.com" class="link">email@example.com</a> address',
+				array('class' => 'link'),
+			),
 
-		$text = 'Text with me@subdomain.küchenschöhn.de address';
-		$expected = 'Text with <a href="mailto:me@subdomain.küchenschöhn.de">me@subdomain.küchenschöhn.de</a> address';
-		$result = $this->Text->autoLinkEmails($text);
+			array(
+				'<p>mark@example.com</p>',
+				'<p><a href="mailto:mark@example.com">mark@example.com</a></p>',
+				array('escape' => false)
+			),
+
+			array(
+				'Some&nbsp;mark@example.com&nbsp;Text',
+				'Some&nbsp;<a href="mailto:mark@example.com">mark@example.com</a>&nbsp;Text',
+				array('escape' => false)
+			),
+		);
+	}
+
+/**
+ * testAutoLinkEmails method
+ *
+ * @param string $text The text to link
+ * @param string $expected The expected results.
+ * @dataProvider autoLinkEmailProvider
+ * @return void
+ */
+	public function testAutoLinkEmails($text, $expected, $attrs = array()) {
+		$result = $this->Text->autoLinkEmails($text, $attrs);
 		$this->assertEquals($expected, $result);
 	}
 

+ 6 - 2
lib/Cake/TestSuite/Fixture/CakeFixtureManager.php

@@ -229,7 +229,9 @@ class CakeFixtureManager {
 				$db = ConnectionManager::getDataSource($fixture->useDbConfig);
 				$db->begin();
 				$this->_setupTable($fixture, $db, $test->dropTables);
-				$fixture->truncate($db);
+				if (!$test->dropTables) {
+					$fixture->truncate($db);
+				}
 				$fixture->insert($db);
 				$db->commit();
 			}
@@ -274,7 +276,9 @@ class CakeFixtureManager {
 				$db = ConnectionManager::getDataSource($fixture->useDbConfig);
 			}
 			$this->_setupTable($fixture, $db, $dropTables);
-			$fixture->truncate($db);
+			if (!$dropTables) {
+				$fixture->truncate($db);
+			}
 			$fixture->insert($db);
 		} else {
 			throw new UnexpectedValueException(__d('cake_dev', 'Referenced fixture class %s not found', $name));

+ 4 - 1
lib/Cake/Utility/Hash.php

@@ -208,7 +208,10 @@ class Hash {
 			if (isset($data[$attr])) {
 				$prop = $data[$attr];
 			}
-			if ($prop === true || $prop === false) {
+			$isBool = is_bool($prop);
+			if ($isBool && is_numeric($val)) {
+				$prop = $prop ? '1' : '0';
+			} elseif ($isBool) {
 				$prop = $prop ? 'true' : 'false';
 			}
 

+ 1 - 1
lib/Cake/Utility/Inflector.php

@@ -164,7 +164,7 @@ class Inflector {
 		'jackanapes', 'Kiplingese', 'Kongoese', 'Lucchese', 'mackerel', 'Maltese', '.*?media',
 		'metadata', 'mews', 'moose', 'mumps', 'Nankingese', 'news', 'nexus', 'Niasese',
 		'Pekingese', 'Piedmontese', 'pincers', 'Pistoiese', 'pliers', 'Portuguese',
-		'proceedings', 'rabies', 'rice', 'rhinoceros', 'salmon', 'Sarawakese', 'scissors',
+		'proceedings', 'rabies', 'research', 'rice', 'rhinoceros', 'salmon', 'Sarawakese', 'scissors',
 		'sea[- ]bass', 'series', 'Shavese', 'shears', 'siemens', 'species', 'swine', 'testes',
 		'trousers', 'trout', 'tuna', 'Vermontese', 'Wenchowese', 'whiting', 'wildebeest',
 		'Yengeese'

+ 1 - 1
lib/Cake/View/Helper/TextHelper.php

@@ -190,7 +190,7 @@ class TextHelper extends AppHelper {
 
 		$atom = '[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]';
 		$text = preg_replace_callback(
-			'/(?<=\s|^|\()(' . $atom . '*(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui',
+			'/(?<=\s|^|\(|\>|\;)(' . $atom . '*(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui',
 			array(&$this, '_insertPlaceholder'),
 			$text
 		);