Browse Source

Merge remote-tracking branch 'origin/2.7' into 3.0

Conflicts:
	.travis.yml
	lib/Cake/Cache/Engine/MemcachedEngine.php
	lib/Cake/Console/Command/SchemaShell.php
	lib/Cake/Console/Command/Task/FixtureTask.php
	lib/Cake/Controller/Component/PaginatorComponent.php
	lib/Cake/Controller/Component/SecurityComponent.php
	lib/Cake/Controller/Controller.php
	lib/Cake/Core/Object.php
	lib/Cake/Error/ExceptionRenderer.php
	lib/Cake/I18n/I18n.php
	lib/Cake/Model/AclNode.php
	lib/Cake/Model/Behavior/TranslateBehavior.php
	lib/Cake/Model/Behavior/TreeBehavior.php
	lib/Cake/Model/Datasource/DboSource.php
	lib/Cake/Model/Model.php
	lib/Cake/Model/ModelValidator.php
	lib/Cake/Network/Http/HttpSocket.php
	lib/Cake/Routing/Dispatcher.php
	lib/Cake/Routing/Router.php
	lib/Cake/Test/Case/I18n/I18nTest.php
	lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php
	lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
	lib/Cake/Test/Case/Routing/DispatcherTest.php
	lib/Cake/Test/Case/Routing/Filter/AssetDispatcherTest.php
	lib/Cake/Test/Case/Utility/ObjectCollectionTest.php
	lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
	lib/Cake/TestSuite/ControllerTestCase.php
	lib/Cake/TestSuite/Fixture/CakeTestFixture.php
	lib/Cake/Utility/CakeTime.php
	lib/Cake/Utility/Inflector.php
	lib/Cake/Utility/ObjectCollection.php
	lib/Cake/View/Helper.php
	lib/Cake/View/Helper/FormHelper.php
	lib/Cake/View/Helper/PaginatorHelper.php
	src/Event/EventManager.php
	src/Log/Engine/ConsoleLog.php
	src/Network/Email/Email.php
	src/Network/Request.php
	src/Routing/Route/Route.php
	src/Shell/Task/ExtractTask.php
	src/View/View.php
	tests/TestCase/Event/EventManagerTest.php
Mark Story 11 years ago
parent
commit
41cb70973b

+ 1 - 0
src/Cache/Engine/MemcachedEngine.php

@@ -162,6 +162,7 @@ class MemcachedEngine extends CacheEngine {
 					'Memcached extension is not build with SASL support'
 				);
 			}
+			$this->_Memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
 			$this->_Memcached->setSaslAuthData(
 				$this->_config['username'],
 				$this->_config['password']

+ 1 - 2
src/Console/ConsoleOptionParser.php

@@ -593,8 +593,7 @@ class ConsoleOptionParser {
  * @return string Generated help.
  */
 	public function help($subcommand = null, $format = 'text', $width = 72) {
-		if (
-			isset($this->_subcommands[$subcommand]) &&
+		if (isset($this->_subcommands[$subcommand]) &&
 			$this->_subcommands[$subcommand]->parser() instanceof self
 		) {
 			$subparser = $this->_subcommands[$subcommand]->parser();

+ 1 - 2
src/Console/ConsoleOutput.php

@@ -159,8 +159,7 @@ class ConsoleOutput {
 	public function __construct($stream = 'php://stdout') {
 		$this->_output = fopen($stream, 'w');
 
-		if (
-			(DS === '\\' && !(bool)env('ANSICON')) ||
+		if ((DS === '\\' && !(bool)env('ANSICON')) ||
 			(function_exists('posix_isatty') && !posix_isatty($this->_output))
 		) {
 			$this->_outputAs = self::PLAIN;

+ 10 - 1
src/Error/ExceptionRenderer.php

@@ -107,10 +107,19 @@ class ExceptionRenderer {
 			$class = App::className('Error', 'Controller', 'Controller');
 			$controller = new $class($request, $response);
 			$controller->startupProcess();
+			$startup = true;
 		} catch (Exception $e) {
-			if (!empty($controller) && isset($controller->RequestHandler)) {
+			$startup = false;
+		}
+
+		// Retry RequestHandler, as another aspect of startupProcess()
+		// could have failed. Ignore any exceptions out of startup, as
+		// there could be userland input data parsers.
+		if ($startup === false && !empty($controller) && isset($controller->RequestHandler)) {
+			try {
 				$event = new Event('Controller.startup', $controller);
 				$controller->RequestHandler->startup($event);
+			} catch (Exception $e) {
 			}
 		}
 		if (empty($controller)) {

+ 1 - 2
src/Log/Engine/ConsoleLog.php

@@ -55,8 +55,7 @@ class ConsoleLog extends BaseLog {
  * @throws \InvalidArgumentException
  */
 	public function __construct(array $config = array()) {
-		if (
-			(DS === '\\' && !(bool)env('ANSICON')) ||
+		if ((DS === '\\' && !(bool)env('ANSICON')) ||
 			(function_exists('posix_isatty') && !posix_isatty($this->_output))
 		) {
 			$this->_defaultConfig['outputAs'] = ConsoleOutput::PLAIN;

+ 2 - 4
src/Network/Request.php

@@ -270,8 +270,7 @@ class Request implements \ArrayAccess {
  */
 	protected function _processPost($data) {
 		$method = $this->env('REQUEST_METHOD');
-		if (
-			in_array($method, array('PUT', 'DELETE', 'PATCH')) &&
+		if (in_array($method, array('PUT', 'DELETE', 'PATCH')) &&
 			strpos($this->env('CONTENT_TYPE'), 'application/x-www-form-urlencoded') === 0
 		) {
 			$data = $this->input();
@@ -347,8 +346,7 @@ class Request implements \ArrayAccess {
 		}
 		$endsWithIndex = '/webroot/index.php';
 		$endsWithLength = strlen($endsWithIndex);
-		if (
-			strlen($uri) >= $endsWithLength &&
+		if (strlen($uri) >= $endsWithLength &&
 			substr($uri, -$endsWithLength) === $endsWithIndex
 		) {
 			$uri = '/';

+ 1 - 2
src/Network/Response.php

@@ -484,8 +484,7 @@ class Response {
 		);
 
 		$charset = false;
-		if (
-			$this->_charset &&
+		if ($this->_charset &&
 			(strpos($this->_contentType, 'text/') === 0 || in_array($this->_contentType, $whitelist))
 		) {
 			$charset = true;

+ 2 - 2
src/Shell/Task/ExtractTask.php

@@ -344,14 +344,14 @@ class ExtractTask extends Shell {
 	protected function _extractTokens() {
 		foreach ($this->_files as $file) {
 			$this->_file = $file;
-			$this->out(sprintf('Processing %s...', $file));
+			$this->out(sprintf('Processing %s...', $file), 1, Shell::VERBOSE);
 
 			$code = file_get_contents($file);
 			$allTokens = token_get_all($code);
 
 			$this->_tokens = [];
 			foreach ($allTokens as $token) {
-				if (!is_array($token) || ($token[0] != T_WHITESPACE && $token[0] != T_INLINE_HTML)) {
+				if (!is_array($token) || ($token[0] !== T_WHITESPACE && $token[0] !== T_INLINE_HTML)) {
 					$this->_tokens[] = $token;
 				}
 			}

+ 1 - 2
src/Utility/Hash.php

@@ -240,8 +240,7 @@ class Hash {
 				if (!preg_match($val, $prop)) {
 					return false;
 				}
-			} elseif (
-				($op === '=' && $prop != $val) ||
+			} elseif (($op === '=' && $prop != $val) ||
 				($op === '!=' && $prop == $val) ||
 				($op === '>' && $prop <= $val) ||
 				($op === '<' && $prop >= $val) ||

+ 1 - 1
src/Utility/Inflector.php

@@ -42,7 +42,7 @@ class Inflector {
 		'/sis$/i' => 'ses',
 		'/([ti])um$/i' => '\1a',
 		'/(p)erson$/i' => '\1eople',
-		'/(m)an$/i' => '\1en',
+		'/(?<!u)(m)an$/i' => '\1en',
 		'/(c)hild$/i' => '\1hildren',
 		'/(buffal|tomat)o$/i' => '\1\2oes',
 		'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i',

+ 18 - 0
src/View/View.php

@@ -417,6 +417,8 @@ class View {
  * @param string|null $layout Layout to use.
  * @return string|null Rendered content or null if content already rendered and returned earlier.
  * @throws \Cake\Core\Exception\Exception If there is an error in the view.
+ * @triggers View.beforeRender $this, array($viewFileName)
+ * @triggers View.afterRender $this, array($viewFileName)
  */
 	public function render($view = null, $layout = null) {
 		if ($this->hasRendered) {
@@ -448,6 +450,8 @@ class View {
  * @param string|null $layout Layout name
  * @return mixed Rendered output, or false on error
  * @throws \Cake\Core\Exception\Exception if there is an error in the view.
+ * @triggers View.beforeLayout $this, array($layoutFileName)
+ * @triggers View.afterLayout $this, array($layoutFileName)
  */
 	public function renderLayout($content, $layout = null) {
 		$layoutFileName = $this->_getLayoutFileName($layout);
@@ -579,6 +583,16 @@ class View {
 	}
 
 /**
+ * Check if a block exists
+ *
+ * @param string $name Name of the block
+ * @return bool
+ */
+	public function exists($name) {
+		return $this->Blocks->exists($name);
+	}
+
+/**
  * End a capturing block. The compliment to View::start()
  *
  * @return void
@@ -707,6 +721,8 @@ class View {
  *   View::$viewVars will be used.
  * @return string Rendered output
  * @throws \LogicException When a block is left open.
+ * @triggers View.beforeRenderFile $this, array($viewFile)
+ * @triggers View.afterRenderFile $this, array($viewFile, $content)
  */
 	protected function _render($viewFile, $data = array()) {
 		if (empty($data)) {
@@ -1043,6 +1059,8 @@ class View {
  * @param array $data Data to render
  * @param array $options Element options
  * @return string
+ * @triggers View.beforeRender $this, array($file)
+ * @triggers View.afterRender $this, array($file, $element)
  */
 	protected function _renderElement($file, $data, $options) {
 		$current = $this->_current;

+ 1 - 2
tests/TestCase/Filesystem/FileTest.php

@@ -81,8 +81,7 @@ class FileTest extends TestCase {
 			'filesize' => filesize($file),
 			'mime' => 'text/plain'
 		);
-		if (
-			!function_exists('finfo_open') &&
+		if (!function_exists('finfo_open') &&
 			(!function_exists('mime_content_type') ||
 			function_exists('mime_content_type') &&
 			mime_content_type($this->File->pwd()) === false)

+ 8 - 0
tests/TestCase/Utility/InflectorTest.php

@@ -180,6 +180,14 @@ class InflectorTest extends TestCase {
  * @return void
  */
 	public function testInflectingPlurals() {
+		$this->assertEquals(Inflector::pluralize('axman'), 'axmen');
+		$this->assertEquals(Inflector::pluralize('man'), 'men');
+		$this->assertEquals(Inflector::pluralize('woman'), 'women');
+		$this->assertEquals(Inflector::pluralize('human'), 'humans');
+		$this->assertEquals(Inflector::pluralize('axman'), 'axmen');
+		$this->assertEquals(Inflector::pluralize('man'), 'men');
+		$this->assertEquals(Inflector::pluralize('woman'), 'women');
+		$this->assertEquals(Inflector::pluralize('human'), 'humans');
 		$this->assertEquals(Inflector::pluralize('categoria'), 'categorias');
 		$this->assertEquals(Inflector::pluralize('house'), 'houses');
 		$this->assertEquals(Inflector::pluralize('powerhouse'), 'powerhouses');