diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 9b402e4ed..fea5ad85b 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -102,10 +102,7 @@ class ExceptionRenderer { if ($exception instanceof CakeException && !$methodExists) { $method = '_cakeError'; - if (empty($template)) { - $template = 'error500'; - } - if ($template == 'internalError') { + if (empty($template) || $template == 'internalError') { $template = 'error500'; } } elseif ($exception instanceof PDOException) { @@ -119,13 +116,12 @@ class ExceptionRenderer { } } - if (Configure::read('debug') == 0) { - if ($method == '_cakeError') { - $method = 'error400'; - } - if ($code == 500) { - $method = 'error500'; - } + $isDebug = (Configure::read('debug') == 0); + if ($isDebug && $method == '_cakeError') { + $method = 'error400'; + } + if ($isDebug && $code == 500) { + $method = 'error500'; } $this->template = $template; $this->method = $method; diff --git a/lib/Cake/Routing/Route/CakeRoute.php b/lib/Cake/Routing/Route/CakeRoute.php index e76dc2bfb..a95c8ce8b 100644 --- a/lib/Cake/Routing/Route/CakeRoute.php +++ b/lib/Cake/Routing/Route/CakeRoute.php @@ -154,7 +154,8 @@ class CakeRoute { if (preg_match('#\/\*\*$#', $route)) { $parsed = preg_replace('#/\\\\\*\\\\\*$#', '(?:/(?P<_trailing_>.*))?', $parsed); $this->_greedy = true; - } elseif (preg_match('#\/\*$#', $route)) { + } + if (preg_match('#\/\*$#', $route)) { $parsed = preg_replace('#/\\\\\*$#', '(?:/(?P<_args_>.*))?', $parsed); $this->_greedy = true; } @@ -163,7 +164,7 @@ class CakeRoute { $this->_compiledRoute = '#^' . $parsed . '[/]*$#'; $this->keys = $names; - //remove defaults that are also keys. They can cause match failures + // Remove defaults that are also keys. They can cause match failures foreach ($this->keys as $key) { unset($this->defaults[$key]); } diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index 6738d2ea4..88ce0023e 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -293,8 +293,9 @@ class Helper extends Object { */ public function assetUrl($path, $options = array()) { if (is_array($path)) { - $path = $this->url($path, !empty($options['fullBase'])); - } elseif (strpos($path, '://') === false) { + return $this->url($path, !empty($options['fullBase'])); + } + if (strpos($path, '://') === false) { if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) { list($plugin, $path) = $this->_View->pluginSplit($path, false); } @@ -322,7 +323,6 @@ class Helper extends Object { $path = $base . $path; } } - return $path; } @@ -460,21 +460,21 @@ class Helper extends Object { * @deprecated This method will be moved to HtmlHelper in 3.0 */ protected function _formatAttribute($key, $value, $escape = true) { - $attribute = ''; if (is_array($value)) { $value = implode(' ' , $value); } - if (is_numeric($key)) { - $attribute = sprintf($this->_minimizedAttributeFormat, $value, $value); - } elseif (in_array($key, $this->_minimizedAttributes)) { - if ($value === 1 || $value === true || $value === 'true' || $value === '1' || $value == $key) { - $attribute = sprintf($this->_minimizedAttributeFormat, $key, $key); - } - } else { - $attribute = sprintf($this->_attributeFormat, $key, ($escape ? h($value) : $value)); + return sprintf($this->_minimizedAttributeFormat, $value, $value); } - return $attribute; + $truthy = array(1, '1', true, 'true', $key); + $isMinimized = in_array($key, $this->_minimizedAttributes); + if ($isMinimized && in_array($value, $truthy, true)) { + return sprintf($this->_minimizedAttributeFormat, $key, $key); + } + if ($isMinimized) { + return ''; + } + return sprintf($this->_attributeFormat, $key, ($escape ? h($value) : $value)); } /**