From f2a4b1e9599e5e7d4493d8368f20af815e4566f3 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 6 Feb 2011 15:51:28 -0200 Subject: [PATCH 01/18] Supporting %e in windows. Fixes #1510. --- cake/libs/view/helpers/time.php | 9 +++++++++ cake/tests/cases/libs/view/helpers/time.test.php | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/cake/libs/view/helpers/time.php b/cake/libs/view/helpers/time.php index 1f4d0be1c..27c690b5a 100644 --- a/cake/libs/view/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -79,6 +79,15 @@ class TimeHelper extends AppHelper { return sprintf("%02d", date('Y', $this->__time) / 100); case 'D': return '%m/%d/%y'; + case 'e': + if (DS === '/') { + return '%e'; + } + $day = date('j', $this->__time); + if ($day < 10) { + $day = ' ' . $day; + } + return $day; case 'eS' : return date('jS', $this->__time); case 'b': diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index bfdbb9ccd..cbe42d2a1 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -731,6 +731,14 @@ class TimeHelperTest extends CakeTestCase { $expected = 4; $this->assertEqual($result, $expected); + $result = $this->Time->convertSpecifiers('%e', $time); + $expected = '14'; + $this->assertEqual($result, $expected); + + $result = $this->Time->convertSpecifiers('%e', strtotime('2011-01-01')); + $expected = ' 1'; + $this->assertEqual($result, $expected); + $result = $this->Time->convertSpecifiers('%x', $time); $expected = '%d/%m/%y'; $this->assertEqual($result, $expected); From 584116524bcf9f217122b050a02b7eb3301afa0f Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 7 Feb 2011 19:19:50 -0500 Subject: [PATCH 02/18] Fixing range option for prototype engine. Fixes #1509 --- cake/libs/view/helpers/prototype_engine.php | 8 ++++++-- .../cases/libs/view/helpers/prototype_engine.test.php | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cake/libs/view/helpers/prototype_engine.php b/cake/libs/view/helpers/prototype_engine.php index 32805a502..d55dc9a65 100644 --- a/cake/libs/view/helpers/prototype_engine.php +++ b/cake/libs/view/helpers/prototype_engine.php @@ -330,10 +330,14 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { unset($options['handle']); if (isset($options['min']) && isset($options['max'])) { - $options['range'] = array($options['min'], $options['max']); + $options['range'] = sprintf('$R(%s,%s)', $options['min'], $options['max']); unset($options['min'], $options['max']); } - $optionString = $this->_processOptions('slider', $options); + $options = $this->_mapOptions('slider', $options); + $options = $this->_prepareCallbacks('slider', $options); + $optionString = $this->_parseOptions( + $options, array_merge(array_keys($this->_callbackArguments['slider']), array('range')) + ); if (!empty($optionString)) { $optionString = ', {' . $optionString . '}'; } diff --git a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php index b838c7124..e5c63b806 100644 --- a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php +++ b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php @@ -348,9 +348,11 @@ class PrototypeEngineHelperTestCase extends CakeTestCase { 'handle' => '#handle', 'change' => 'change();', 'complete' => 'complete();', - 'value' => 4 + 'value' => 4, + 'min' => 10, + 'max' => 100 )); - $expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, sliderValue:4});'; + $expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, range:$R(10,100), sliderValue:4});'; $this->assertEqual($result, $expected); } From 9a940709abc24f0c97bd32973ffdc5639e91fc01 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 7 Feb 2011 20:59:01 -0500 Subject: [PATCH 03/18] Removing unsupported options from PrototypeEngine. Fixes #1516 --- cake/libs/view/helpers/prototype_engine.php | 5 +++-- cake/tests/cases/libs/view/helpers/prototype_engine.test.php | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cake/libs/view/helpers/prototype_engine.php b/cake/libs/view/helpers/prototype_engine.php index d55dc9a65..848b676a2 100644 --- a/cake/libs/view/helpers/prototype_engine.php +++ b/cake/libs/view/helpers/prototype_engine.php @@ -45,10 +45,8 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { 'error' => 'onFailure' ), 'sortable' => array( - 'start' => 'onStart', 'sort' => 'onChange', 'complete' => 'onUpdate', - 'distance' => 'snap', ), 'drag' => array( 'snapGrid' => 'snap', @@ -262,6 +260,9 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { * * #### Note: Requires scriptaculous to be loaded. * + * The scriptaculous implementation of sortables does not suppot the 'start' + * and 'distance' options. + * * @param array $options Array of options for the sortable. * @return string Completed sortable script. * @access public diff --git a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php index e5c63b806..0ca94724c 100644 --- a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php +++ b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php @@ -268,13 +268,11 @@ class PrototypeEngineHelperTestCase extends CakeTestCase { function testSortable() { $this->Proto->get('#myList'); $result = $this->Proto->sortable(array( - 'distance' => 5, - 'start' => 'onStart', 'complete' => 'onComplete', 'sort' => 'onSort', 'wrapCallbacks' => false )); - $expected = 'var jsSortable = Sortable.create($("myList"), {onChange:onSort, onStart:onStart, onUpdate:onComplete, snap:5});'; + $expected = 'var jsSortable = Sortable.create($("myList"), {onChange:onSort, onUpdate:onComplete});'; $this->assertEqual($result, $expected); } From a5fb2cf8a73ca5f6095a4b271751ac1488f1f0fe Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 8 Feb 2011 21:53:12 -0500 Subject: [PATCH 04/18] Fixing issue where fixtures without field definitions would drop tables, even though they had no way to re-create them. Fixes #1519 --- cake/tests/cases/libs/cake_test_fixture.test.php | 4 ++++ cake/tests/lib/cake_test_fixture.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/cake/tests/cases/libs/cake_test_fixture.test.php b/cake/tests/cases/libs/cake_test_fixture.test.php index a64d4e3e6..6e6667dde 100644 --- a/cake/tests/cases/libs/cake_test_fixture.test.php +++ b/cake/tests/cases/libs/cake_test_fixture.test.php @@ -391,6 +391,10 @@ class CakeTestFixtureTest extends CakeTestCase { $this->criticDb->setReturnValueAt(1, 'execute', false); $return = $Fixture->drop($this->criticDb); $this->assertFalse($return); + + unset($Fixture->fields); + $return = $Fixture->drop($this->criticDb); + $this->assertFalse($return); } /** diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index 00daa38ef..91264d891 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -153,6 +153,9 @@ class CakeTestFixture extends Object { * @access public */ function drop(&$db) { + if (empty($this->fields)) { + return false; + } $this->Schema->_build(array($this->table => $this->fields)); return ( $db->execute($db->dropSchema($this->Schema), array('log' => false)) !== false From 71f76080a2a254bb203681b3db7047e665915ade Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 9 Feb 2011 21:19:05 -0500 Subject: [PATCH 05/18] Fixing issue where creating cookies in the beforeFilter would result in cookies with the wrong expiry time. Thanks 'RabidFire' for the patch. Fixes #1523 --- cake/libs/controller/components/cookie.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cake/libs/controller/components/cookie.php b/cake/libs/controller/components/cookie.php index 002395b7b..e3a122ca5 100644 --- a/cake/libs/controller/components/cookie.php +++ b/cake/libs/controller/components/cookie.php @@ -166,6 +166,9 @@ class CookieComponent extends Object { function initialize(&$controller, $settings) { $this->key = Configure::read('Security.salt'); $this->_set($settings); + if (isset($this->time)) { + $this->__expire($this->time); + } } /** From 42c2f3011bcef22b4ed13bf9197856e62d51faf4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 11 Feb 2011 21:49:00 -0500 Subject: [PATCH 06/18] Applying fix from 'Mark Mitchell' to expose PeriodicalExecuter in the callback. Fixes #1529 --- cake/libs/view/helpers/ajax.php | 2 +- cake/tests/cases/libs/view/helpers/ajax.test.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index 9c153c3a2..251ea7f18 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -315,7 +315,7 @@ class AjaxHelper extends AppHelper { function remoteTimer($options = null) { $frequency = (isset($options['frequency'])) ? $options['frequency'] : 10; $callback = $this->remoteFunction($options); - $code = "new PeriodicalExecuter(function() {{$callback}}, $frequency)"; + $code = "new PeriodicalExecuter(function(pe) {{$callback}}, $frequency)"; return $this->Javascript->codeBlock($code); } diff --git a/cake/tests/cases/libs/view/helpers/ajax.test.php b/cake/tests/cases/libs/view/helpers/ajax.test.php index 20cd15bc8..d06bf4a71 100644 --- a/cake/tests/cases/libs/view/helpers/ajax.test.php +++ b/cake/tests/cases/libs/view/helpers/ajax.test.php @@ -566,49 +566,49 @@ class AjaxHelperTest extends CakeTestCase { $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'frequency' => 25)); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'complete' => 'complete();')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, onComplete:function(request, json) {complete();}})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'complete' => 'complete();', 'create' => 'create();')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, onComplete:function(request, json) {complete();}, onCreate:function(request, xhr) {create();}})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'exception' => 'alert(exception);')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, onException:function(request, exception) {alert(exception);}})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'contentType' => 'application/x-www-form-urlencoded')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, contentType:\'application/x-www-form-urlencoded\'})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'method' => 'get', 'encoding' => 'utf-8')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, method:\'get\', encoding:\'utf-8\'})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'postBody' => 'var1=value1')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, postBody:\'var1=value1\'})')) . '/', $result); } /** From 63caf566fb82df7b4f9ddd2019773e92827637ec Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 12:22:29 -0500 Subject: [PATCH 07/18] Adding some tests around invalidFields() and fieldList options. Closes #1534 --- cake/tests/cases/libs/model/model_validation.test.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cake/tests/cases/libs/model/model_validation.test.php b/cake/tests/cases/libs/model/model_validation.test.php index bbf00996e..d0b3fb648 100644 --- a/cake/tests/cases/libs/model/model_validation.test.php +++ b/cake/tests/cases/libs/model/model_validation.test.php @@ -131,13 +131,14 @@ class ModelValidationTest extends BaseModelTest { $TestModel =& new ValidationTest1(); $TestModel->validate = $validate = array( 'title' => array( - 'rule' => 'customValidator', + 'rule' => 'alphaNumeric', 'required' => true ), 'name' => array( - 'rule' => 'allowEmpty', + 'rule' => 'alphaNumeric', 'required' => true )); + $TestModel->set(array('title' => '$$', 'name' => '##')); $TestModel->invalidFields(array('fieldList' => array('title'))); $expected = array( 'title' => 'This field cannot be left blank' @@ -175,9 +176,9 @@ class ModelValidationTest extends BaseModelTest { */ function testInvalidFieldsWhitelist() { $TestModel =& new ValidationTest1(); - $TestModel->validate = $validate = array( + $TestModel->validate = array( 'title' => array( - 'rule' => 'customValidator', + 'rule' => 'alphaNumeric', 'required' => true ), 'name' => array( @@ -186,7 +187,7 @@ class ModelValidationTest extends BaseModelTest { )); $TestModel->whitelist = array('name'); - $TestModel->save(array('name' => '#$$#')); + $TestModel->save(array('name' => '#$$#', 'title' => '$$$$')); $expected = array('name' => 'This field cannot be left blank'); $this->assertEqual($TestModel->validationErrors, $expected); From a95d4acf09d7bd96aa986837b386f3a1ecc7b829 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 16 Feb 2011 21:14:32 -0500 Subject: [PATCH 08/18] Removing unused code, and adding a realpath() to document_root, so symlinks work a bit better. --- cake/dispatcher.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 729bb7a44..bc4b5a711 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -359,8 +359,7 @@ class Dispatcher extends Object { } $this->webroot = $base . '/'; - $docRoot = env('DOCUMENT_ROOT'); - $script = realpath(env('SCRIPT_FILENAME')); + $docRoot = realpath(env('DOCUMENT_ROOT')); $docRootContainsWebroot = strpos($docRoot, $dir . '/' . $webroot); if (!empty($base) || !$docRootContainsWebroot) { From ca3e606ec8829fdbbeca4cf2bd04cee02d9cacdf Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 16 Feb 2011 22:08:20 -0500 Subject: [PATCH 09/18] Fixing failing tests caused by me forgetting to run tests in [703272965106532764817b661ef08791d29464ac] --- cake/tests/cases/dispatcher.test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 0255829b5..942e1f757 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1173,7 +1173,7 @@ class DispatcherTest extends CakeTestCase { $result = $Dispatcher->baseUrl(); $expected = '/index.php'; $this->assertEqual($expected, $result); - $expectedWebroot = '/'; + $expectedWebroot = '/app/webroot/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.baseUrl', '/CakeBB/app/webroot/index.php'); @@ -1287,7 +1287,7 @@ class DispatcherTest extends CakeTestCase { $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = array('missingController', array(array( 'className' => 'SomeControllerController', - 'webroot' => '/', + 'webroot' => '/app/webroot/', 'url' => 'some_controller/home/param:value/param2:value2', 'base' => '/index.php' ))); @@ -1310,7 +1310,7 @@ class DispatcherTest extends CakeTestCase { $expected = array('privateAction', array(array( 'className' => 'SomePagesController', 'action' => '_protected', - 'webroot' => '/', + 'webroot' => '/app/webroot/', 'url' => 'some_pages/_protected/param:value/param2:value2', 'base' => '/index.php' ))); @@ -1333,7 +1333,7 @@ class DispatcherTest extends CakeTestCase { $expected = array('missingAction', array(array( 'className' => 'SomePagesController', 'action' => 'home', - 'webroot' => '/', + 'webroot' => '/app/webroot/', 'url' => '/index.php/some_pages/home/param:value/param2:value2', 'base' => '/index.php' ))); @@ -1348,7 +1348,7 @@ class DispatcherTest extends CakeTestCase { $expected = array('missingAction', array(array( 'className' => 'SomePagesController', 'action' => 'redirect', - 'webroot' => '/', + 'webroot' => '/app/webroot/', 'url' => '/index.php/some_pages/redirect/param:value/param2:value2', 'base' => '/index.php' ))); @@ -1455,7 +1455,7 @@ class DispatcherTest extends CakeTestCase { $result = $Dispatcher->dispatch($url); $expected = array('missingController', array(array( 'className' => 'Controller', - 'webroot' => '/', + 'webroot' => '/app/webroot/', 'url' => 'http://google.com', 'base' => '/index.php' ))); From 0e7f2efdb161db0b907ea0cdfc547ca8f348271e Mon Sep 17 00:00:00 2001 From: 0x20h Date: Tue, 15 Feb 2011 21:21:39 +0100 Subject: [PATCH 10/18] Fixing notice errors caused by accessing headers in po files that don't exist. Fixes #1515 Signed-off-by: mark_story --- cake/libs/i18n.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cake/libs/i18n.php b/cake/libs/i18n.php index f1234d46a..3fb94f336 100644 --- a/cake/libs/i18n.php +++ b/cake/libs/i18n.php @@ -321,8 +321,10 @@ class I18n extends Object { $this->__domains[$domain][$this->__lang][$this->category] = array(); return $domain; } - - if ($head = $this->__domains[$domain][$this->__lang][$this->category][""]) { + + if (isset($this->__domains[$domain][$this->__lang][$this->category][""])) { + $head = $this->__domains[$domain][$this->__lang][$this->category][""]; + foreach (explode("\n", $head) as $line) { $header = strtok($line,":"); $line = trim(strtok("\n")); From d0b7d3355d72fbb5046dca83a0f6efae0e7db3c2 Mon Sep 17 00:00:00 2001 From: Victor Widell Date: Mon, 21 Feb 2011 04:38:07 -0800 Subject: [PATCH 11/18] $this->data[$habtmKey] could be a string, meaning $this->data[$habtmKey][$habtmKey] would be the first character of that string. Probably not what you want. Fixes #1549 Signed-off-by: mark_story --- cake/libs/view/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index ecd731b90..b8bc471fe 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -708,7 +708,7 @@ class Helper extends Overloadable { } $habtmKey = $this->field(); - if (empty($result) && isset($this->data[$habtmKey][$habtmKey])) { + if (empty($result) && isset($this->data[$habtmKey][$habtmKey]) && is_array($this->data[$habtmKey])) { $result = $this->data[$habtmKey][$habtmKey]; } elseif (empty($result) && isset($this->data[$habtmKey]) && is_array($this->data[$habtmKey])) { if (ClassRegistry::isKeySet($habtmKey)) { From 1f9bbbce53a15f3471bf3814da7b835a19274078 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 21 Feb 2011 10:48:34 -0500 Subject: [PATCH 12/18] Pulling windows specific tests into a separate test method. --- .../cases/libs/view/helpers/time.test.php | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index cbe42d2a1..5501750cf 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -731,14 +731,6 @@ class TimeHelperTest extends CakeTestCase { $expected = 4; $this->assertEqual($result, $expected); - $result = $this->Time->convertSpecifiers('%e', $time); - $expected = '14'; - $this->assertEqual($result, $expected); - - $result = $this->Time->convertSpecifiers('%e', strtotime('2011-01-01')); - $expected = ' 1'; - $this->assertEqual($result, $expected); - $result = $this->Time->convertSpecifiers('%x', $time); $expected = '%d/%m/%y'; $this->assertEqual($result, $expected); @@ -748,6 +740,25 @@ class TimeHelperTest extends CakeTestCase { $this->assertEqual($result, $expected); } +/** + * test convert %e on windows. + * + * @return void + */ + function testConvertPercentE() { + if ($this->skipIf(DS !== '\\', 'Cannot run windows tests on non-windows OS')) { + return; + } + $time = strtotime('Thu Jan 14 11:43:39 2010'); + $result = $this->Time->convertSpecifiers('%e', $time); + $expected = '14'; + $this->assertEqual($result, $expected); + + $result = $this->Time->convertSpecifiers('%e', strtotime('2011-01-01')); + $expected = ' 1'; + $this->assertEqual($result, $expected); + } + /** * test formatting dates taking in account preferred i18n locale file * From 21a9904a71b24e753049a31a47b6dab26fde6743 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 21 Feb 2011 17:55:15 -0300 Subject: [PATCH 13/18] Adding a protection to cake console be executed in driver root (windows). Fixes #1408. --- cake/console/cake.bat | 2 +- cake/console/cake.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cake/console/cake.bat b/cake/console/cake.bat index 7e35cfcb9..87ee1c7d9 100644 --- a/cake/console/cake.bat +++ b/cake/console/cake.bat @@ -26,7 +26,7 @@ SET app=%0 SET lib=%~dp0 -php -q "%lib%cake.php" -working "%CD%" %* +php -q "%lib%cake.php" -working "%CD% " %* echo. diff --git a/cake/console/cake.php b/cake/console/cake.php index a4c89b520..f5cf287e4 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -501,6 +501,9 @@ class ShellDispatcher { } $params = str_replace('\\', '/', $params); + if (isset($params['working'])) { + $params['working'] = trim($params['working']); + } if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) { if (empty($this->params['app']) && $params['working'] != $params['root']) { $params['root'] = dirname($params['working']); @@ -516,8 +519,10 @@ class ShellDispatcher { $params['root'] .= '/' . dirname($params['app']); } - $params['app'] = basename($params['app']); - $params['working'] = rtrim($params['root'], '/') . '/' . $params['app']; + $params['working'] = rtrim($params['root'], '/'); + if (!$isWin || !preg_match('/^[A-Z]:$/i', $params['app'])) { + $params['working'] .= '/' . $params['app']; + } if (!empty($matches[0]) || !empty($isWin)) { $params = str_replace('/', '\\', $params); From 52163b4b05c3febc9643bc5e81366af7800314a6 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 22 Feb 2011 21:23:15 -0300 Subject: [PATCH 14/18] Allowing strings in cc and bcc. Fixes #1553. --- cake/libs/controller/components/email.php | 10 +++------- .../cases/libs/controller/components/email.test.php | 4 ++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index fd4ed3479..43ee594b7 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -561,11 +561,7 @@ class EmailComponent extends Object{ $headers = array(); if ($this->delivery == 'smtp') { - if (is_array($this->to)) { - $headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), $this->to)); - } else { - $headers['To'] = $this->_formatAddress($this->to); - } + $headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->to)); } $headers['From'] = $this->_formatAddress($this->from); @@ -580,11 +576,11 @@ class EmailComponent extends Object{ } if (!empty($this->cc)) { - $headers['cc'] = implode(', ', array_map(array($this, '_formatAddress'), $this->cc)); + $headers['Cc'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->cc)); } if (!empty($this->bcc) && $this->delivery != 'smtp') { - $headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), $this->bcc)); + $headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->bcc)); } if ($this->delivery == 'smtp') { $headers['Subject'] = $this->_encode($this->subject); diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 541ed4f2a..78fb7b45c 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -740,6 +740,8 @@ HTMLBLOC; function testSendDebug() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; + $this->Controller->EmailTest->cc = 'cc@example.com'; + $this->Controller->EmailTest->bcc = 'bcc@example.com'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = 'noreply@example.com'; $this->Controller->EmailTest->template = null; @@ -752,6 +754,8 @@ HTMLBLOC; $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: noreply@example.com\n/', $result); $this->assertPattern('/From: noreply@example.com\n/', $result); + $this->assertPattern('/Cc: cc@example.com\n/', $result); + $this->assertPattern('/Bcc: bcc@example.com\n/', $result); $this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); From 139d6b3133bfe1068a1fbee50fd1605d28dbe561 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 23 Feb 2011 21:15:39 -0500 Subject: [PATCH 15/18] Changing the checks surrounding dataExpression to use empty() instead of isset() so unexpected things don't happen if you ever use dataExpression = false. Fixes #1521 --- cake/libs/view/helpers/jquery_engine.php | 2 +- cake/libs/view/helpers/mootools_engine.php | 2 +- cake/libs/view/helpers/prototype_engine.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/view/helpers/jquery_engine.php b/cake/libs/view/helpers/jquery_engine.php index 16668d08b..54e9a7589 100644 --- a/cake/libs/view/helpers/jquery_engine.php +++ b/cake/libs/view/helpers/jquery_engine.php @@ -269,7 +269,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper { unset($options['update']); } $callbacks = array('success', 'error', 'beforeSend', 'complete'); - if (isset($options['dataExpression'])) { + if (!empty($options['dataExpression'])) { $callbacks[] = 'data'; unset($options['dataExpression']); } diff --git a/cake/libs/view/helpers/mootools_engine.php b/cake/libs/view/helpers/mootools_engine.php index 2ade6069c..693d84597 100644 --- a/cake/libs/view/helpers/mootools_engine.php +++ b/cake/libs/view/helpers/mootools_engine.php @@ -252,7 +252,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper { } $options['url'] = $url; $options = $this->_prepareCallbacks('request', $options); - if (isset($options['dataExpression'])) { + if (!empty($options['dataExpression'])) { $callbacks[] = 'data'; unset($options['dataExpression']); } elseif (!empty($data)) { diff --git a/cake/libs/view/helpers/prototype_engine.php b/cake/libs/view/helpers/prototype_engine.php index 848b676a2..7d49ae07e 100644 --- a/cake/libs/view/helpers/prototype_engine.php +++ b/cake/libs/view/helpers/prototype_engine.php @@ -244,7 +244,7 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { } $safe = array_keys($this->_callbackArguments['request']); $options = $this->_prepareCallbacks('request', $options, $safe); - if (isset($options['dataExpression'])) { + if (!empty($options['dataExpression'])) { $safe[] = 'parameters'; unset($options['dataExpression']); } From e05c6cd83fb35ac2f25234147309776f39fb2556 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 24 Feb 2011 16:43:13 -0500 Subject: [PATCH 16/18] Fixing issue where actions starting with a prefix but not followed by an _ would get mangled when going through router::url(). Fixes #1556 --- cake/libs/router.php | 2 +- cake/tests/cases/libs/router.test.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 622dae829..86e77daae 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -822,7 +822,7 @@ class Router { } elseif (isset($url[$prefix]) && !$url[$prefix]) { unset($url[$prefix]); } - if (isset($url[$prefix]) && strpos($url['action'], $prefix) === 0) { + if (isset($url[$prefix]) && strpos($url['action'], $prefix . '_') === 0) { $url['action'] = substr($url['action'], strlen($prefix) + 1); } } diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 8346dfec8..0d199655d 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1513,6 +1513,10 @@ class RouterTest extends CakeTestCase { $result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true)); $expected = '/protected/images/edit/1'; $this->assertEqual($result, $expected); + + $result = Router::url(array('action' => 'protectededit', 1, 'protected' => true)); + $expected = '/protected/images/protectededit/1'; + $this->assertEqual($result, $expected); $result = Router::url(array('action' => 'edit', 1, 'protected' => true)); $expected = '/protected/images/edit/1'; From b80955c9fe1f03db93009cd920bf21c6d7285d77 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 25 Feb 2011 18:50:50 -0500 Subject: [PATCH 17/18] Adding newlines to the builtin email template. Fixes issues with long lines. Refs #857 --- cake/libs/view/elements/email/html/default.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/view/elements/email/html/default.ctp b/cake/libs/view/elements/email/html/default.ctp index 70e28b22e..61fb69bb0 100644 --- a/cake/libs/view/elements/email/html/default.ctp +++ b/cake/libs/view/elements/email/html/default.ctp @@ -21,6 +21,6 @@ $content = explode("\n", $content); foreach ($content as $line): - echo '

' . $line . '

'; + echo '

' . $line . "

\n"; endforeach; ?> \ No newline at end of file From e9011badb59ffbfba75d90dcce53935785c6c8aa Mon Sep 17 00:00:00 2001 From: Ceeram Date: Mon, 28 Feb 2011 21:16:17 +0100 Subject: [PATCH 18/18] Ensure both node() and afterSave() use ->name Fixes #1564 --- cake/libs/model/behaviors/acl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/behaviors/acl.php b/cake/libs/model/behaviors/acl.php index 63b85a6f0..41cc50899 100644 --- a/cake/libs/model/behaviors/acl.php +++ b/cake/libs/model/behaviors/acl.php @@ -96,7 +96,7 @@ class AclBehavior extends ModelBehavior { } $data = array( 'parent_id' => isset($parent[0][$type]['id']) ? $parent[0][$type]['id'] : null, - 'model' => $model->alias, + 'model' => $model->name, 'foreign_key' => $model->id ); if (!$created) {