Navigation Menu

Skip to content

Commit

Permalink
Fix infinite loop when minYear/maxYear are not int.
Browse files Browse the repository at this point in the history
Refs #2361
  • Loading branch information
markstory committed Dec 12, 2011
1 parent 205bfb5 commit 8bb6f88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 3 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -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);
}

/**
Expand Down
12 changes: 2 additions & 10 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -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);
}
Expand Down

0 comments on commit 8bb6f88

Please sign in to comment.