From b3c9c1615e36a200a308f7bd434eaad5ff4b89b8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 13 Feb 2015 21:40:50 -0500 Subject: [PATCH 01/10] Fix doubly linking URLs starting with // Fixes #5889 --- lib/Cake/Test/Case/View/Helper/TextHelperTest.php | 4 ++++ lib/Cake/View/Helper/TextHelper.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php index 41ef4b296..87d81b14a 100644 --- a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php @@ -127,6 +127,10 @@ class TextHelperTest extends CakeTestCase { $expected = 'Text with a partial www.cakephp.org URL and test@cakephp\.org email address'; $this->assertRegExp('#^' . $expected . '$#', $result); + $text = 'Text with a partial link link'; + $result = $this->Text->autoLink($text, array('escape' => false)); + $this->assertEquals($text, $result); + $text = 'This is a test text with URL http://www.cakephp.org'; $expected = 'This is a test text with URL http://www.cakephp.org'; $result = $this->Text->autoLink($text); diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index 92d30ace6..2a2a536b4 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -114,7 +114,7 @@ class TextHelper extends AppHelper { $text ); $text = preg_replace_callback( - '#(?)(?)(? Date: Thu, 19 Feb 2015 07:34:27 -0500 Subject: [PATCH 02/10] Update version number to 2.6.2 --- lib/Cake/VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/VERSION.txt b/lib/Cake/VERSION.txt index 8ede76ab1..4c3efdfeb 100644 --- a/lib/Cake/VERSION.txt +++ b/lib/Cake/VERSION.txt @@ -17,4 +17,4 @@ // @license http://www.opensource.org/licenses/mit-license.php MIT License // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -2.6.1 +2.6.2 From 4f2ed156121d01be9c0d3e685cbcae71b3db06c2 Mon Sep 17 00:00:00 2001 From: Michael Houghton Date: Sat, 21 Feb 2015 10:21:37 +0000 Subject: [PATCH 03/10] fix for confirm message on the bake templates --- lib/Cake/Console/Templates/default/views/index.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Templates/default/views/index.ctp b/lib/Cake/Console/Templates/default/views/index.ctp index d3d4caaf3..28d5bcc60 100644 --- a/lib/Cake/Console/Templates/default/views/index.ctp +++ b/lib/Cake/Console/Templates/default/views/index.ctp @@ -48,7 +48,7 @@ echo "\t\t\n"; echo "\t\t\tHtml->link(__('View'), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; echo "\t\t\tHtml->link(__('Edit'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; - echo "\t\t\tForm->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array(), __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; + echo "\t\t\tForm->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; echo "\t\t\n"; echo "\t\n"; From 831fe53f793e13fbef42633ed85ee6da5a3ba928 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 22 Feb 2015 22:39:38 -0500 Subject: [PATCH 04/10] Ignore LC_TIME category when extracting messages. Given that we use the specific LC_TIME file format, it doesn't make much sense to extract translated strings into a PO file that cannot be used later on. Refs #5933 --- lib/Cake/Console/Command/Task/ExtractTask.php | 6 +++++- .../Console/Command/Task/ExtractTaskTest.php | 16 ++++++++++------ lib/Cake/Test/test_app/View/Pages/extract.ctp | 2 ++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index 570649170..c9f5712cc 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -432,6 +432,7 @@ class ExtractTask extends AppShell { $category = isset($category) ? $category : 6; $category = (int)$category; $categoryName = $categories[$category]; + $domain = isset($domain) ? $domain : 'default'; $details = array( 'file' => $this->_file, @@ -443,7 +444,10 @@ class ExtractTask extends AppShell { if (isset($context)) { $details['msgctxt'] = $context; } - $this->_addTranslation($categoryName, $domain, $singular, $details); + // Skip LC_TIME files as we use a special file format for them. + if ($categoryName !== 'LC_TIME') { + $this->_addTranslation($categoryName, $domain, $singular, $details); + } } else { $this->_markerError($this->_file, $line, $functionName, $count); } diff --git a/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php index 238803acf..363afb2ff 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php @@ -162,19 +162,19 @@ class ExtractTaskTest extends CakeTestCase { $this->assertContains('msgid "double \\"quoted\\""', $result, 'Strings with quotes not handled correctly'); $this->assertContains("msgid \"single 'quoted'\"", $result, 'Strings with quotes not handled correctly'); - $pattern = '/\#: (\\\\|\/)extract\.ctp:34\nmsgid "letter"/'; + $pattern = '/\#: (\\\\|\/)extract\.ctp:36\nmsgid "letter"/'; $this->assertRegExp($pattern, $result, 'Strings with context should not overwrite strings without context'); - $pattern = '/\#: (\\\\|\/)extract\.ctp:35;37\nmsgctxt "A"\nmsgid "letter"/'; + $pattern = '/\#: (\\\\|\/)extract\.ctp:37;39\nmsgctxt "A"\nmsgid "letter"/'; $this->assertRegExp($pattern, $result, 'Should contain string with context "A"'); - $pattern = '/\#: (\\\\|\/)extract\.ctp:36\nmsgctxt "B"\nmsgid "letter"/'; + $pattern = '/\#: (\\\\|\/)extract\.ctp:38\nmsgctxt "B"\nmsgid "letter"/'; $this->assertRegExp($pattern, $result, 'Should contain string with context "B"'); - $pattern = '/\#: (\\\\|\/)extract\.ctp:38\nmsgid "%d letter"\nmsgid_plural "%d letters"/'; + $pattern = '/\#: (\\\\|\/)extract\.ctp:40\nmsgid "%d letter"\nmsgid_plural "%d letters"/'; $this->assertRegExp($pattern, $result, 'Plural strings with context should not overwrite strings without context'); - $pattern = '/\#: (\\\\|\/)extract\.ctp:39\nmsgctxt "A"\nmsgid "%d letter"\nmsgid_plural "%d letters"/'; + $pattern = '/\#: (\\\\|\/)extract\.ctp:41\nmsgctxt "A"\nmsgid "%d letter"\nmsgid_plural "%d letters"/'; $this->assertRegExp($pattern, $result, 'Should contain plural string with context "A"'); // extract.ctp - reading the domain.pot @@ -209,12 +209,16 @@ class ExtractTaskTest extends CakeTestCase { $this->Task->expects($this->never())->method('_stop'); $this->Task->execute(); - $this->assertTrue(file_exists($this->path . DS . 'LC_TIME' . DS . 'default.pot')); + $this->assertTrue(file_exists($this->path . DS . 'LC_NUMERIC' . DS . 'default.pot')); + $this->assertFalse(file_exists($this->path . DS . 'LC_TIME' . DS . 'default.pot')); $result = file_get_contents($this->path . DS . 'default.pot'); $pattern = '/\#: .*extract\.ctp:31\n/'; $this->assertNotRegExp($pattern, $result); + + $pattern = '/\#: .*extract\.ctp:33\n/'; + $this->assertNotRegExp($pattern, $result); } /** diff --git a/lib/Cake/Test/test_app/View/Pages/extract.ctp b/lib/Cake/Test/test_app/View/Pages/extract.ctp index 3331f2fd4..63e8c73a5 100644 --- a/lib/Cake/Test/test_app/View/Pages/extract.ctp +++ b/lib/Cake/Test/test_app/View/Pages/extract.ctp @@ -28,6 +28,8 @@ __('Hot features!' . ' Join us #cakephp on IRC. We\'d love to help you get started'); // Category +echo __c('You have a new message (category: LC_NUMERIC).', 4); +// LC_TIME is skipped. echo __c('You have a new message (category: LC_TIME).', 5); // Context From 5342605d9200bc04b3acc43292221b108163ca35 Mon Sep 17 00:00:00 2001 From: AD7six Date: Mon, 23 Feb 2015 15:21:39 +0000 Subject: [PATCH 05/10] The parentheses were unbalanced --- lib/Cake/Console/Templates/default/views/index.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Templates/default/views/index.ctp b/lib/Cake/Console/Templates/default/views/index.ctp index 28d5bcc60..375edc682 100644 --- a/lib/Cake/Console/Templates/default/views/index.ctp +++ b/lib/Cake/Console/Templates/default/views/index.ctp @@ -48,7 +48,7 @@ echo "\t\t\n"; echo "\t\t\tHtml->link(__('View'), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; echo "\t\t\tHtml->link(__('Edit'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; - echo "\t\t\tForm->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; + echo "\t\t\tForm->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}']))); ?>\n"; echo "\t\t\n"; echo "\t\n"; From b151295f1b63a41fdd462d7cd130073fa4d02e7a Mon Sep 17 00:00:00 2001 From: AD7six Date: Mon, 23 Feb 2015 16:45:02 +0000 Subject: [PATCH 06/10] Add a better test for the index being correct --- .../Console/Command/Task/ViewTaskTest.php | 4 +- lib/Cake/Test/bake_compare/View/index.ctp | 58 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 lib/Cake/Test/bake_compare/View/index.ctp diff --git a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php index 6b02d12ba..086a2b8b8 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php @@ -323,12 +323,14 @@ class ViewTaskTest extends CakeTestCase { public function testBakeIndex() { $this->Task->controllerName = 'ViewTaskComments'; + $expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'View' . DS . 'index.ctp'); $this->Task->expects($this->at(0))->method('createFile') ->with( TMP . 'ViewTaskComments' . DS . 'index.ctp', - $this->stringContains("\$viewTaskComment['Article']['title']") + $expected ); $this->Task->bake('index', true); + } /** diff --git a/lib/Cake/Test/bake_compare/View/index.ctp b/lib/Cake/Test/bake_compare/View/index.ctp new file mode 100644 index 000000000..d7bb68982 --- /dev/null +++ b/lib/Cake/Test/bake_compare/View/index.ctp @@ -0,0 +1,58 @@ +
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Paginator->sort('id'); ?>Paginator->sort('article_id'); ?>Paginator->sort('user_id'); ?>Paginator->sort('comment'); ?>Paginator->sort('published'); ?>Paginator->sort('created'); ?>Paginator->sort('updated'); ?>
  + Html->link($viewTaskComment['Article']['title'], array('controller' => 'view_task_articles', 'action' => 'view', $viewTaskComment['Article']['id'])); ?> +       + Html->link(__('View'), array('action' => 'view', $viewTaskComment['ViewTaskComment']['id'])); ?> + Html->link(__('Edit'), array('action' => 'edit', $viewTaskComment['ViewTaskComment']['id'])); ?> + Form->postLink(__('Delete'), array('action' => 'delete', $viewTaskComment['ViewTaskComment']['id']), array('confirm' => __('Are you sure you want to delete # %s?', $viewTaskComment['ViewTaskComment']['id']))); ?> +
+

+ Paginator->counter(array( + 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') + )); + ?>

+
+ Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled')); + echo $this->Paginator->numbers(array('separator' => '')); + echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled')); + ?> +
+
+
+

+
    +
  • Html->link(__('New View Task Comment'), array('action' => 'add')); ?>
  • +
  • Html->link(__('List View Task Articles'), array('controller' => 'view_task_articles', 'action' => 'index')); ?>
  • +
  • Html->link(__('New Article'), array('controller' => 'view_task_articles', 'action' => 'add')); ?>
  • +
+
From 5066bc33b4a06333ba1325f047115fa33f5995c2 Mon Sep 17 00:00:00 2001 From: AD7six Date: Mon, 23 Feb 2015 16:46:43 +0000 Subject: [PATCH 07/10] Fix whitespace for paginator counter call --- lib/Cake/Console/Templates/default/views/index.ctp | 2 +- lib/Cake/Test/bake_compare/View/index.ctp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Console/Templates/default/views/index.ctp b/lib/Cake/Console/Templates/default/views/index.ctp index 375edc682..cf77c0ed9 100644 --- a/lib/Cake/Console/Templates/default/views/index.ctp +++ b/lib/Cake/Console/Templates/default/views/index.ctp @@ -59,7 +59,7 @@

Paginator->counter(array( - 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') + 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') )); ?>"; ?>

diff --git a/lib/Cake/Test/bake_compare/View/index.ctp b/lib/Cake/Test/bake_compare/View/index.ctp index d7bb68982..b2738e4b3 100644 --- a/lib/Cake/Test/bake_compare/View/index.ctp +++ b/lib/Cake/Test/bake_compare/View/index.ctp @@ -37,7 +37,7 @@

Paginator->counter(array( - 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') + 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') )); ?>

From d7d2516dc1b1e724607b7cb01b113bdc487a35b8 Mon Sep 17 00:00:00 2001 From: AD7six Date: Mon, 23 Feb 2015 17:22:55 +0000 Subject: [PATCH 08/10] Remove unwanted whitespace --- lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php index 086a2b8b8..c5ab4762f 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php @@ -330,7 +330,6 @@ class ViewTaskTest extends CakeTestCase { $expected ); $this->Task->bake('index', true); - } /** From ea79cf5d137fb3c78bdc3009256764c2849caea5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 25 Feb 2015 20:52:35 -0500 Subject: [PATCH 09/10] Fix words with WWW in them being autolinked. Don't autolink words that don't have `www.` in them. Fixes #5968 --- lib/Cake/Test/Case/View/Helper/TextHelperTest.php | 4 ++++ lib/Cake/View/Helper/TextHelper.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php index 87d81b14a..a38fa38f1 100644 --- a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php @@ -117,6 +117,10 @@ class TextHelperTest extends CakeTestCase { * @return void */ public function testAutoLink() { + $text = 'The AWWWARD show happened today'; + $result = $this->Text->autoLink($text); + $this->assertEquals($text, $result); + $text = 'This is a test text'; $expected = 'This is a test text'; $result = $this->Text->autoLink($text); diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index 2a2a536b4..753434cc5 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -114,7 +114,7 @@ class TextHelper extends AppHelper { $text ); $text = preg_replace_callback( - '#(?)(?)(? Date: Wed, 25 Feb 2015 21:34:15 -0500 Subject: [PATCH 10/10] Allow numeric sorts in PaginatorComponent. When paginating data, we should not ignore numerically indexed order conditions. Instead they should be handled similar to Model::find(). This creates a slightly different behavior when model's have default sorting applied as more default sort options forms will be honoured. Refs #5964 --- .../Controller/Component/PaginatorComponent.php | 4 ++++ .../Component/PaginatorComponentTest.php | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Controller/Component/PaginatorComponent.php b/lib/Cake/Controller/Component/PaginatorComponent.php index 94a606552..e0203acef 100644 --- a/lib/Cake/Controller/Component/PaginatorComponent.php +++ b/lib/Cake/Controller/Component/PaginatorComponent.php @@ -388,6 +388,10 @@ class PaginatorComponent extends Component { if (!empty($options['order']) && is_array($options['order'])) { $order = array(); foreach ($options['order'] as $key => $value) { + if (is_int($key)) { + $key = $value; + $value = 'asc'; + } $field = $key; $alias = $object->alias; if (strpos($key, '.') !== false) { diff --git a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php index 5fa098314..4ce1ffe99 100644 --- a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php @@ -454,6 +454,13 @@ class PaginatorComponentTest extends CakeTestCase { $this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id')); $this->assertTrue(!isset($Controller->PaginatorControllerPost->lastQueries[1]['contain'])); + $Controller->Paginator->settings = array( + 'order' => array('PaginatorControllerPost.author_id') + ); + $result = $Controller->Paginator->paginate('PaginatorControllerPost'); + $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); + $this->assertEquals(array(1, 3, 2), Hash::extract($result, '{n}.PaginatorControllerPost.id')); + $Controller->request->params['named'] = array('page' => '-1'); $Controller->Paginator->settings = array( 'PaginatorControllerPost' => array( @@ -606,7 +613,7 @@ class PaginatorComponentTest extends CakeTestCase { $Controller->PaginatorControllerPost->order = array('PaginatorControllerPost.id'); $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array()); - $this->assertEmpty($result['order']); + $this->assertEquals(array('PaginatorControllerPost.id' => 'asc'), $result['order']); $Controller->PaginatorControllerPost->order = 'PaginatorControllerPost.id'; $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array()); @@ -617,7 +624,10 @@ class PaginatorComponentTest extends CakeTestCase { 'PaginatorControllerPost.created' => 'asc' ); $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array()); - $expected = array('PaginatorControllerPost.created' => 'asc'); + $expected = array( + 'PaginatorControllerPost.id' => 'asc', + 'PaginatorControllerPost.created' => 'asc' + ); $this->assertEquals($expected, $result['order']); }