Skip to content

Commit 1174bf2

Browse files
committed
ACPT-860: Indexation time is calculated incorrectly
1 parent 093ddc6 commit 1174bf2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/code/Magento/Indexer/Console/Command/IndexerReindexCommand.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
101101

102102
$output->write($indexer->getTitle() . ' index ');
103103

104-
$startTime = microtime(true);
104+
$startTime = new \DateTimeImmutable();
105105
$indexerConfig = $this->getConfig()->getIndexer($indexer->getId());
106106
$sharedIndex = $indexerConfig['shared_index'] ?? null;
107107

@@ -112,10 +112,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
112112
$this->sharedIndexesComplete[] = $sharedIndex;
113113
}
114114
}
115-
$resultTime = microtime(true) - $startTime;
115+
$endTime = new \DateTimeImmutable();
116+
$interval = $startTime->diff($endTime);
117+
$days = $interval->format('%d');
118+
$hours = $days > 0 ? $days * 24 + $interval->format('%H') : $interval->format('%H');
119+
$minutes = $interval->format('%I');
120+
$seconds = $interval->format('%S');
116121

117122
$output->writeln(
118-
__('has been rebuilt successfully in %time', ['time' => gmdate('H:i:s', (int) $resultTime)])
123+
__('has been rebuilt successfully in %1:%2:%3', $hours, $minutes, $seconds)
119124
);
120125
} catch (\Throwable $e) {
121126
$output->writeln('process error during indexation process:');

0 commit comments

Comments
 (0)