From 6e5381a4e3cd3a1cb3f161be333fd12ea6a9b0a3 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sat, 20 Jun 2015 23:27:32 +0200 Subject: [PATCH 1/5] Cleanup method calls. --- lib/Cake/View/Helper/HtmlHelper.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 07acb91b2..8a7bc15a8 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -279,12 +279,12 @@ class HtmlHelper extends AppHelper { if (isset($options['link'])) { $options['link'] = $this->assetUrl($options['link']); if (isset($options['rel']) && $options['rel'] === 'icon') { - $out = sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('block', 'link'), ' ', ' ')); + $out = sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('block', 'link'))); $options['rel'] = 'shortcut icon'; } - $out .= sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('block', 'link'), ' ', ' ')); + $out .= sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('block', 'link'))); } else { - $out = sprintf($this->_tags['meta'], $this->_parseAttributes($options, array('block', 'type'), ' ', ' ')); + $out = sprintf($this->_tags['meta'], $this->_parseAttributes($options, array('block', 'type'))); } if (empty($options['block'])) { @@ -565,7 +565,7 @@ class HtmlHelper extends AppHelper { $url = str_replace(Configure::read('App.jsBaseUrl'), 'cjs/', $url); } } - $attributes = $this->_parseAttributes($options, array('block', 'once'), ' '); + $attributes = $this->_parseAttributes($options, array('block', 'once')); $out = sprintf($this->_tags['javascriptlink'], $url, $attributes); if (empty($options['block'])) { @@ -601,7 +601,7 @@ class HtmlHelper extends AppHelper { } unset($options['inline'], $options['safe']); - $attributes = $this->_parseAttributes($options, array('block'), ' '); + $attributes = $this->_parseAttributes($options, array('block')); $out = sprintf($this->_tags['javascriptblock'], $attributes, $script); if (empty($options['block'])) { @@ -828,7 +828,7 @@ class HtmlHelper extends AppHelper { unset($options['url']); } - $image = sprintf($this->_tags['image'], $path, $this->_parseAttributes($options, null, ' ', ' ')); + $image = sprintf($this->_tags['image'], $path, $this->_parseAttributes($options)); if ($url) { return sprintf($this->_tags['link'], $this->url($url), null, $image); @@ -939,7 +939,7 @@ class HtmlHelper extends AppHelper { } else { $tag = 'tag'; } - return sprintf($this->_tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name); + return sprintf($this->_tags[$tag], $name, $this->_parseAttributes($options), $text, $name); } /** @@ -957,7 +957,7 @@ class HtmlHelper extends AppHelper { array_shift($args); foreach ($args as &$arg) { if (is_array($arg)) { - $arg = $this->_parseAttributes($arg, null, ' ', ''); + $arg = $this->_parseAttributes($arg); } } return vsprintf($this->_tags[$tag], $args); @@ -1008,7 +1008,7 @@ class HtmlHelper extends AppHelper { if ($text === null) { $tag = 'parastart'; } - return sprintf($this->_tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text); + return sprintf($this->_tags[$tag], $this->_parseAttributes($options), $text); } /** @@ -1144,7 +1144,7 @@ class HtmlHelper extends AppHelper { $options = array(); } $items = $this->_nestedListItem($list, $options, $itemOptions, $tag); - return sprintf($this->_tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $items); + return sprintf($this->_tags[$tag], $this->_parseAttributes($options), $items); } /** @@ -1170,7 +1170,7 @@ class HtmlHelper extends AppHelper { } elseif (isset($itemOptions['odd']) && $index % 2 !== 0) { $itemOptions['class'] = $itemOptions['odd']; } - $out .= sprintf($this->_tags['li'], $this->_parseAttributes($itemOptions, array('even', 'odd'), ' ', ''), $item); + $out .= sprintf($this->_tags['li'], $this->_parseAttributes($itemOptions, array('even', 'odd')), $item); $index++; } return $out; From 26630991a6eb07a2a947e036c359f97519ec654e Mon Sep 17 00:00:00 2001 From: Humberto Pereira Date: Sat, 13 Jun 2015 12:45:27 -0400 Subject: [PATCH 2/5] CakeShells should not print html in case of a error --- lib/Cake/Console/ShellDispatcher.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index 30f37aa09..204237751 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -177,6 +177,9 @@ class ShellDispatcher { } set_exception_handler($exception['consoleHandler']); set_error_handler($error['consoleHandler'], Configure::read('Error.level')); + + App::uses('Debugger', 'Utility'); + Debugger::getInstance()->output('txt'); } /** From 77150eb6f6675f1dc7ca9a366135826c53cbeb91 Mon Sep 17 00:00:00 2001 From: Humberto Pereira Date: Sat, 13 Jun 2015 12:48:29 -0400 Subject: [PATCH 3/5] fixed tests cases to print html --- lib/Cake/Test/Case/Error/ErrorHandlerTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php index aa7448d64..18930737b 100644 --- a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php @@ -19,6 +19,7 @@ App::uses('ErrorHandler', 'Error'); App::uses('Controller', 'Controller'); App::uses('Router', 'Routing'); +App::uses('Debugger', 'Utility'); /** * A faulty ExceptionRenderer to test nesting. @@ -92,6 +93,8 @@ class ErrorHandlerTest extends CakeTestCase { set_error_handler('ErrorHandler::handleError'); $this->_restoreError = true; + Debugger::getInstance()->output('html'); + ob_start(); $wrong .= ''; $result = ob_get_clean(); @@ -123,6 +126,8 @@ class ErrorHandlerTest extends CakeTestCase { set_error_handler('ErrorHandler::handleError'); $this->_restoreError = true; + Debugger::getInstance()->output('html'); + ob_start(); trigger_error('Test error', $error); From fc57e43a5b2994bd5b482009676bbd28331a4488 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Sun, 21 Jun 2015 12:13:09 +0200 Subject: [PATCH 4/5] Adjust tests. --- lib/Cake/Test/Case/Network/Email/CakeEmailTest.php | 2 +- lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php | 1 - lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php | 10 +++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index c6bed1d73..90f55c364 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -1570,7 +1570,7 @@ class CakeEmailTest extends CakeTestCase { $server .= ':' . env('SERVER_PORT'); } - $expected = 'cool image'; + $expected = 'cool image'; $result = $this->CakeEmail->send(); $this->assertContains($expected, $result['message']); } diff --git a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php index 873f6a955..ea16d3232 100644 --- a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php @@ -1755,7 +1755,6 @@ class HtmlHelperTest extends CakeTestCase { $result = $this->Html->meta('keywords', 'these, are, some, meta, keywords'); $this->assertTags($result, array('meta' => array('name' => 'keywords', 'content' => 'these, are, some, meta, keywords'))); - $this->assertRegExp('/\s+\/>$/', $result); $result = $this->Html->meta('description', 'this is the meta description'); $this->assertTags($result, array('meta' => array('name' => 'description', 'content' => 'this is the meta description'))); diff --git a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php index 5b37bf4f0..cb271c6b0 100644 --- a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php @@ -2857,7 +2857,7 @@ class PaginatorHelperTest extends CakeTestCase { 'paramType' => 'querystring' ) ); - $expected = ''; + $expected = ''; $result = $this->Paginator->meta(); $this->assertSame($expected, $result); } @@ -2878,7 +2878,7 @@ class PaginatorHelperTest extends CakeTestCase { 'paramType' => 'querystring' ) ); - $expected = ''; + $expected = ''; $this->Paginator->meta(array('block' => true)); $result = $this->View->fetch('meta'); $this->assertSame($expected, $result); @@ -2900,7 +2900,7 @@ class PaginatorHelperTest extends CakeTestCase { 'paramType' => 'querystring' ) ); - $expected = ''; + $expected = ''; $result = $this->Paginator->meta(); $this->assertSame($expected, $result); } @@ -2921,8 +2921,8 @@ class PaginatorHelperTest extends CakeTestCase { 'paramType' => 'querystring' ) ); - $expected = ''; - $expected .= ''; + $expected = ''; + $expected .= ''; $result = $this->Paginator->meta(); $this->assertSame($expected, $result); } From 2f616a9e0cdf1cba7ff657a232e7c5452af44091 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 24 Jun 2015 23:39:26 -0400 Subject: [PATCH 5/5] Fix greedy regex operators in Postgres driver. `*` is greedy in regex, and needs to be escaped so that SQL operators don't cause invalid SQL conditions to be created. Refs #6877 --- lib/Cake/Model/Datasource/Database/Postgres.php | 2 +- lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 21d82b191..033527ae0 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -98,7 +98,7 @@ class Postgres extends DboSource { * * @var array */ - protected $_sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', '~', '~*', '!~', '!~*', 'similar to'); + protected $_sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', '~', '~\*', '\!~', '\!~\*', 'similar to'); /** * Connects to the database using options in the given configuration array. diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php index d51fd7c87..03a964de6 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php @@ -490,6 +490,10 @@ class PostgresTest extends CakeTestCase { $this->assertSame(' WHERE "name" ~* \'[a-z_]+\'', $this->Dbo->conditions(array('name ~*' => '[a-z_]+'))); $this->assertSame(' WHERE "name" !~ \'[a-z_]+\'', $this->Dbo->conditions(array('name !~' => '[a-z_]+'))); $this->assertSame(' WHERE "name" !~* \'[a-z_]+\'', $this->Dbo->conditions(array('name !~*' => '[a-z_]+'))); + $this->assertSame( + ' WHERE EXTRACT( \'YEAR\' FROM "User"."birthday" ) = 2015', + $this->Dbo->conditions(array('EXTRACT( \'YEAR\' FROM User.birthday )' => 2015)) + ); } /**