From eb13242680731f8c1cf82786670f5fe40d06f6f3 Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 18 Jun 2013 09:39:43 +0200 Subject: [PATCH 1/6] assert proper array access for _dateTimeSelected() --- lib/Cake/View/Helper/FormHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index b3bff1032..d3a1481cc 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2272,8 +2272,8 @@ class FormHelper extends AppHelper { */ protected function _dateTimeSelected($select, $fieldName, $attributes) { if ((empty($attributes['value']) || $attributes['value'] === true) && $value = $this->value($fieldName)) { - if (is_array($value) && isset($value[$select])) { - $attributes['value'] = $value[$select]; + if (is_array($value)) { + $attributes['value'] = isset($value[$select]) ? $value[$select] : null; } else { if (empty($value)) { if (!$attributes['empty']) { From 1b1943954b60233157f5c83c425377ae6417b5cf Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 18 Jun 2013 23:49:42 +0200 Subject: [PATCH 2/6] CakeSession improvements --- lib/Cake/Model/Datasource/CakeSession.php | 32 ++++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index 63e0f9404..51b6f8a46 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -213,7 +213,7 @@ class CakeSession { * @return boolean True if variable is there */ public static function check($name = null) { - if (!self::started() && !self::start()) { + if (!self::start()) { return false; } if (empty($name)) { @@ -223,9 +223,17 @@ class CakeSession { } /** - * Returns the Session id + * Returns the session id. + * Calling this method will not auto start the session. You might have to manually + * assert a started session. * - * @param string $id + * Passing an id into it, you can also replace the session id if the session + * has not already been started. + * Note that depending on the session handler, not all characters are allowed + * within the session id. For example, the file session handler only allows + * characters in the range a-z A-Z 0-9 , (comma) and - (minus). + * + * @param string $id Id to replace the current session id * @return string Session id */ public static function id($id = null) { @@ -254,7 +262,7 @@ class CakeSession { } /** - * Used to write new data to _SESSION, since PHP doesn't like us setting the _SESSION var itself + * Used to write new data to _SESSION, since PHP doesn't like us setting the _SESSION var itself. * * @param array $old Set of old variables => values * @param array $new New set of variable => value @@ -333,10 +341,10 @@ class CakeSession { } /** - * Get / Set the userAgent + * Get / Set the user agent * - * @param string $userAgent Set the userAgent - * @return void + * @param string $userAgent Set the user agent + * @return string Current user agent */ public static function userAgent($userAgent = null) { if ($userAgent) { @@ -355,7 +363,7 @@ class CakeSession { * @return mixed The value of the session variable */ public static function read($name = null) { - if (!self::started() && !self::start()) { + if (!self::start()) { return false; } if (is_null($name)) { @@ -393,7 +401,7 @@ class CakeSession { * @return boolean True if the write was successful, false if the write failed */ public static function write($name, $value = null) { - if (!self::started() && !self::start()) { + if (!self::start()) { return false; } if (empty($name)) { @@ -418,9 +426,7 @@ class CakeSession { * @return void */ public static function destroy() { - if (!self::started()) { - self::start(); - } + self::start(); session_destroy(); self::clear(); } @@ -620,7 +626,7 @@ class CakeSession { * @return void */ protected static function _checkValid() { - if (!self::started() && !self::start()) { + if (!self::start()) { self::$valid = false; return false; } From dc3f9113b03653a7fe9ec44354540404dd7e2cbf Mon Sep 17 00:00:00 2001 From: Lucas Machado Date: Thu, 13 Jun 2013 16:10:18 -0300 Subject: [PATCH 3/6] Fix to the date input year field Create the field if no value is informed only to the maxYear and not to the current date. --- .../Test/Case/View/Helper/FormHelperTest.php | 25 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 6 ++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 02b5d8c97..d7e538142 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -6628,6 +6628,31 @@ class FormHelperTest extends CakeTestCase { $this->assertEquals($result, $expected); } +/** + * testInputDateMaxYear method + * + * Let's say we want to only allow users born from + * 2006 to 2008 to register + * This beeing the first singup page, we still don't have any data + * + * @return void + */ + public function testInputDateMaxYear() { + $this->Form->request->data = array(); + $this->Form->create('User'); + $result = $this->Form->input('birthday', + array( + 'label' => false, + 'div' => false, + 'type' => 'date', + 'dateFormat' => 'DMY', + 'minYear' => 2006, + 'maxYear' => 2008 + ) + ); + $this->assertContains('value="2008" selected="selected"', $result); + } + /** * testTextArea method * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index d3a1481cc..fee50b610 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2359,7 +2359,11 @@ class FormHelper extends AppHelper { } if ($attributes['value'] === null && $attributes['empty'] != true) { - $attributes['value'] = time(); + if(!empty($attributes['maxYear']) && $attributes['maxYear'] < date('Y')) { + $attributes['value'] = strtotime(date($attributes['maxYear'] . '-m-d')); + } else { + $attributes['value'] = time(); + } } if (!empty($attributes['value'])) { From 68db74d32deea447c12b8e90c53fbdac1ec062d5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 19 Jun 2013 15:06:51 -0400 Subject: [PATCH 4/6] Cleanup from previous commit. Refs #GH-1352 --- .../Test/Case/View/Helper/FormHelperTest.php | 33 +++++++++---------- lib/Cake/View/Helper/FormHelper.php | 5 ++- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index d7e538142..23eb8e7a1 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -6630,27 +6630,26 @@ class FormHelperTest extends CakeTestCase { /** * testInputDateMaxYear method - * - * Let's say we want to only allow users born from - * 2006 to 2008 to register - * This beeing the first singup page, we still don't have any data + * + * Let's say we want to only allow users born from 2006 to 2008 to register + * This being the first singup page, we still don't have any data * * @return void */ public function testInputDateMaxYear() { - $this->Form->request->data = array(); - $this->Form->create('User'); - $result = $this->Form->input('birthday', - array( - 'label' => false, - 'div' => false, - 'type' => 'date', - 'dateFormat' => 'DMY', - 'minYear' => 2006, - 'maxYear' => 2008 - ) - ); - $this->assertContains('value="2008" selected="selected"', $result); + $this->Form->request->data = array(); + $this->Form->create('User'); + $result = $this->Form->input('birthday', + array( + 'label' => false, + 'div' => false, + 'type' => 'date', + 'dateFormat' => 'DMY', + 'minYear' => 2006, + 'maxYear' => 2008 + ) + ); + $this->assertContains('value="2008" selected="selected"', $result); } /** diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index fee50b610..bf2290b9b 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2359,10 +2359,9 @@ class FormHelper extends AppHelper { } if ($attributes['value'] === null && $attributes['empty'] != true) { - if(!empty($attributes['maxYear']) && $attributes['maxYear'] < date('Y')) { + $attributes['value'] = time(); + if (!empty($attributes['maxYear']) && $attributes['maxYear'] < date('Y')) { $attributes['value'] = strtotime(date($attributes['maxYear'] . '-m-d')); - } else { - $attributes['value'] = time(); } } From 2418ea0a57c6855bab46b6bd227cd6bfc3e664c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Fri, 21 Jun 2013 16:49:31 +0200 Subject: [PATCH 5/6] Fixed typo in AuthComponent::redirectUrl --- lib/Cake/Controller/Component/AuthComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index eb31cd554..112e1d1ee 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -643,7 +643,7 @@ class AuthComponent extends Component { } /** - * Get the URL a use should be redirected to upon login. + * Get the URL a user should be redirected to upon login. * * Pass an URL in to set the destination a user should be redirected to upon * logging in. From 94815a74f1e590f0f62d9f177a10c209d530a8f6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jun 2013 17:47:08 -0400 Subject: [PATCH 6/6] Add ordering to prevent occasional pgsql failures. --- lib/Cake/Test/Case/Model/ModelWriteTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 1ec06c96b..eaa339ab3 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -6533,7 +6533,9 @@ class ModelWriteTest extends BaseModelTest { )); $TestModel->saveAll($data, array('fieldList' => $fieldList)); - $result = $TestModel->find('all'); + $result = $TestModel->find('all', array( + 'order' => 'Post.id ASC', + )); $expected = array( 'Post' => array ( 'id' => '4',