Skip to content

Commit 147b334

Browse files
MAGETWO-71762: Bug fix, prevent displaying 0000-00-00 00:00:00 as anything else in admin grids #10598
2 parents 5e12808 + ef64c7b commit 147b334

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

app/code/Magento/Ui/Component/Listing/Columns/Date.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ public function prepareDataSource(array $dataSource)
5353
{
5454
if (isset($dataSource['data']['items'])) {
5555
foreach ($dataSource['data']['items'] as & $item) {
56-
if (isset($item[$this->getData('name')])) {
56+
if (isset($item[$this->getData('name')])
57+
&& $item[$this->getData('name')] !== "0000-00-00 00:00:00"
58+
) {
5759
$date = $this->timezone->date(new \DateTime($item[$this->getData('name')]));
5860
$timezone = isset($this->getConfiguration()['timezone'])
5961
? $this->booleanUtils->convert($this->getConfiguration()['timezone'])

app/code/Magento/Ui/Test/Unit/Component/Listing/Columns/DateTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,14 @@ public function testPrepareDataSource()
8989
$result = $this->model->prepareDataSource(['data' => ['items' => [$item]]]);
9090
$this->assertEquals(self::TEST_TIME, $result['data']['items'][0]['field_name']);
9191
}
92+
93+
public function testPrepareDataSourceWithZeroDate()
94+
{
95+
$zeroDate = '0000-00-00 00:00:00';
96+
$item = ['test_data' => 'some_data', 'field_name' => $zeroDate];
97+
$this->timezoneMock->expects($this->never())->method('date');
98+
99+
$result = $this->model->prepareDataSource(['data' => ['items' => [$item]]]);
100+
$this->assertEquals($zeroDate, $result['data']['items'][0]['field_name']);
101+
}
92102
}

0 commit comments

Comments
 (0)