Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix infinite loop when minYear/maxYear are not int.

Refs #2361
  • Loading branch information...
commit 8bb6f8803c60d68e110f208e5e6276b1a524cb22 1 parent 205bfb5
@markstory markstory authored
View
3  lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -5624,6 +5624,9 @@ public function testYear() {
'/select',
);
$this->assertTags($result, $expected);
+
+ $result = $this->Form->year('published', array(), array(), array('empty' => false));
+ $this->assertContains('data[Contact][published][year]', $result);
}
/**
View
12 lib/Cake/View/Helper/FormHelper.php
@@ -2461,17 +2461,9 @@ protected function _generateOptions($name, $options = array()) {
case 'year':
$current = intval(date('Y'));
- if (!isset($options['min'])) {
- $min = $current - 20;
- } else {
- $min = $options['min'];
- }
+ $min = !isset($options['min']) ? $current - 20 : (int)$options['min'];
+ $max = !isset($options['max']) ? $current + 20 : (int)$options['max'];
- if (!isset($options['max'])) {
- $max = $current + 20;
- } else {
- $max = $options['max'];
- }
if ($min > $max) {
list($min, $max) = array($max, $min);
}
Please sign in to comment.
Something went wrong with that request. Please try again.