mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Fixing issue in FormHelper where CURRENT_TIMESTAMP or other invalid data could cause a notice error. Fixes #1508
This commit is contained in:
parent
f3812342c2
commit
cf50cbdd9d
2 changed files with 15 additions and 2 deletions
|
@ -1843,8 +1843,11 @@ class FormHelper extends AppHelper {
|
|||
if ($time[0] == 0 && $timeFormat == '12') {
|
||||
$time[0] = 12;
|
||||
}
|
||||
$hour = $time[0];
|
||||
$min = $time[1];
|
||||
$hour = $min = null;
|
||||
if (isset($time[1])) {
|
||||
$hour = $time[0];
|
||||
$min = $time[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4494,6 +4494,16 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertPattern('/<option[^<>]+value="06"[^<>]+selected="selected"[^>]*>June<\/option>/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that bogus non-date time data doesn't cause errors.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testDateTimeWithBogusData() {
|
||||
$result = $this->Form->dateTime('Contact.updated', 'DMY', '12', 'CURRENT_TIMESTAMP');
|
||||
$this->assertNoPattern('/selected="selected">\d/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testFormDateTimeMulti method
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue