Skip to content

Commit 8bb6f88

Browse files
committed
Fix infinite loop when minYear/maxYear are not int.
Refs #2361
1 parent 205bfb5 commit 8bb6f88

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

lib/Cake/Test/Case/View/Helper/FormHelperTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5624,6 +5624,9 @@ public function testYear() {
56245624
'/select',
56255625
);
56265626
$this->assertTags($result, $expected);
5627+
5628+
$result = $this->Form->year('published', array(), array(), array('empty' => false));
5629+
$this->assertContains('data[Contact][published][year]', $result);
56275630
}
56285631

56295632
/**

lib/Cake/View/Helper/FormHelper.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,17 +2461,9 @@ protected function _generateOptions($name, $options = array()) {
24612461
case 'year':
24622462
$current = intval(date('Y'));
24632463

2464-
if (!isset($options['min'])) {
2465-
$min = $current - 20;
2466-
} else {
2467-
$min = $options['min'];
2468-
}
2464+
$min = !isset($options['min']) ? $current - 20 : (int)$options['min'];
2465+
$max = !isset($options['max']) ? $current + 20 : (int)$options['max'];
24692466

2470-
if (!isset($options['max'])) {
2471-
$max = $current + 20;
2472-
} else {
2473-
$max = $options['max'];
2474-
}
24752467
if ($min > $max) {
24762468
list($min, $max) = array($max, $min);
24772469
}

0 commit comments

Comments
 (0)