Description
Preconditions and environment
magento/magento-cloud-metapackage": "2.4.5
I was unable to naturally reproduce this problem. But it seems that problem is that Indexer state is saved and beforeSave method sets “updated” value to timestamp: https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Indexer/Model/Indexer/State.php#L183
After that Magento\Indexer\Model\Indexer->getLatestUpdated() is called and it passes that timestamp to DateTime object constructor: https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Indexer/Model/Indexer.php#L378
This results with “Exception: Failed to parse time string” error
Steps to reproduce
Don't know how to reproduce this. Found these errors in logs, caused by 3rd party module. Best to use code snipped:
`<?php
require 'app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
function _log($msg)
{
print_r($msg);
print "\n";
}
/** @var \Magento\Framework\ObjectManager\ObjectManager $objectManager */
$objectManager = $bootstrap->getObjectManager();
$dateTime = new \DateTime();
/** @var \Magento\Indexer\Model\Indexer $indexer */
$indexer = $objectManager->get('\Magento\Indexer\Model\Indexer');
$indexer->load('customer_grid');
$indexer->getView()->getState()->setUpdated($dateTime->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT));
$indexer->getView()->getState()->setMode(\Magento\Framework\Mview\View\StateInterface::MODE_ENABLED);
// NO ERRORS
_log($indexer->getLatestUpdated());
$state = $indexer->getState();
$status = $state->getStatus();
$state->setStatus('test');
$state->setStatus($status);
$state->save();
// ERROR
_log($indexer->getLatestUpdated());`
Expected result
No errors I guess
Actual result
Exception: Failed to parse time string (1699254906) at position 7 (9): Unexpected character in /vendor/magento/module-indexer/Model/Indexer.php:378
Additional information
No response
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.