Skip to content

Commit

Permalink
MAGETWO-71762: Bug fix, prevent displaying 0000-00-00 00:00:00 as a…
Browse files Browse the repository at this point in the history
…nything else in admin grids #10598
  • Loading branch information
ishakhsuvarov authored Aug 23, 2017
2 parents 5e12808 + ef64c7b commit 147b334
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/code/Magento/Ui/Component/Listing/Columns/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
if (isset($item[$this->getData('name')])) {
if (isset($item[$this->getData('name')])
&& $item[$this->getData('name')] !== "0000-00-00 00:00:00"
) {
$date = $this->timezone->date(new \DateTime($item[$this->getData('name')]));
$timezone = isset($this->getConfiguration()['timezone'])
? $this->booleanUtils->convert($this->getConfiguration()['timezone'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,14 @@ public function testPrepareDataSource()
$result = $this->model->prepareDataSource(['data' => ['items' => [$item]]]);
$this->assertEquals(self::TEST_TIME, $result['data']['items'][0]['field_name']);
}

public function testPrepareDataSourceWithZeroDate()
{
$zeroDate = '0000-00-00 00:00:00';
$item = ['test_data' => 'some_data', 'field_name' => $zeroDate];
$this->timezoneMock->expects($this->never())->method('date');

$result = $this->model->prepareDataSource(['data' => ['items' => [$item]]]);
$this->assertEquals($zeroDate, $result['data']['items'][0]['field_name']);
}
}

0 comments on commit 147b334

Please sign in to comment.