datagrid
datagrid copied to clipboard
NetteDatabaseDataSource.php - Unhandled date creation in filters
NetteDatabaseDataSource.php - there is unhandled date creation in filters. It crasches when \DateTime::createFromFormat returns false. It's necessary to check if $date_from and $date_to is false.
` public function applyFilterDateRange(Filter\FilterDateRange $filter) { $conditions = $filter->getCondition();
$value_from = $conditions[$filter->getColumn()]['from'];
$value_to = $conditions[$filter->getColumn()]['to'];
if ($value_from) {
$date_from = \DateTime::createFromFormat($filter->getPhpFormat(), $value_from);
if ($date_from !== false) {
$date_from->setTime(0, 0, 0);
$this->applyWhere("DATE({$filter->getColumn()})", $date_from->format('Y-m-d'), '>=');
}
}
if ($value_to) {
$date_to = \DateTime::createFromFormat($filter->getPhpFormat(), $value_to);
if ($date_to !== false) {
$date_to->setTime(23, 59, 59);
$this->applyWhere("DATE({$filter->getColumn()})", $date_to->format('Y-m-d'), '<=');
}
}
}
`