ho-nl / magento2-ReachDigital_BetterIndexer

14 stars 5 forks source link

feat(GOM2-2320): update for magento 2.4.6-p1 #11

Closed Maikel-Koek closed 1 year ago

Maikel-Koek commented 1 year ago

See https://github.com/magento/magento2/blob/2.4.6-p1/app/code/Magento/Indexer/Console/Command/IndexerReindexCommand.php

--- vendor_orig/magento/module-indexer/Console/Command/IndexerReindexCommand.php    2022-03-08 00:52:02
+++ vendor/magento/module-indexer/Console/Command/IndexerReindexCommand.php 2023-02-23 14:11:00
@@ -101,7 +101,7 @@

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

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

@@ -112,10 +112,15 @@
                         $this->sharedIndexesComplete[] = $sharedIndex;
                     }
                 }
-                $resultTime = microtime(true) - $startTime;
+                $endTime = new \DateTimeImmutable();
+                $interval = $startTime->diff($endTime);
+                $days = $interval->format('%d');
+                $hours = $days > 0 ? $days * 24 + $interval->format('%H') : $interval->format('%H');
+                $minutes = $interval->format('%I');
+                $seconds = $interval->format('%S');

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