Symfony-Bundle
Symfony-Bundle copied to clipboard
Format Datetime on saveReports
Hi,
I have a locale in French on my system :
[alice@wonderland ~]$ locale
LANG=fr_FR.UTF-8
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=
As a result, the floats are with commas :
French format : 1564147674,2589 US format : 1564147674.2589
On the file Symfony-Bundle/Cron/Manager.php at line 53 :
$dbReport->setRunAt(\DateTime::createFromFormat('U.u', (string) $report->getStartTime()));
The format used is the American format.
With number_format it is possible to fix this problem. https://php.net/manual/en/function.number-format.php
Here is an example :
$now = DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''));
Thank you for doing the necessary. Best regards.
I have the same problem in my production from time to time.
Doctrine\DBAL\Types\ConversionException: Could not convert PHP value '' of type 'boolean' to type 'datetime'. Expected one of the following types: null, DateTime
#15 /app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ConversionException.php(72): Doctrine\DBAL\Types\ConversionException::conversionFailedInvalidType
#14 /app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php(44): Doctrine\DBAL\Types\DateTimeType::convertToDatabaseValue
#13 /app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php(99): Doctrine\DBAL\Statement::bindValue
#12 /app/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php(283): Doctrine\ORM\Persisters\Entity\BasicEntityPersister::executeInserts
#11 /app/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(1075): Doctrine\ORM\UnitOfWork::executeInserts
#10 /app/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(388): Doctrine\ORM\UnitOfWork::commit
#9 /app/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(359): Doctrine\ORM\EntityManager::flush
#8 /app/vendor/cron/cron-bundle/Cron/Manager.php(57): Cron\CronBundle\Cron\Manager::saveReports
#7 /app/vendor/cron/cron-bundle/Command/CronRunCommand.php(63): Cron\CronBundle\Command\CronRunCommand::execute
#6 /app/vendor/symfony/console/Command/Command.php(255): Symfony\Component\Console\Command\Command::run
#5 /app/vendor/symfony/console/Application.php(933): Symfony\Component\Console\Application::doRunCommand
#4 /app/vendor/symfony/framework-bundle/Console/Application.php(87): Symfony\Bundle\FrameworkBundle\Console\Application::doRunCommand
#3 /app/vendor/symfony/console/Application.php(272): Symfony\Component\Console\Application::doRun
#2 /app/vendor/symfony/framework-bundle/Console/Application.php(73): Symfony\Bundle\FrameworkBundle\Console\Application::doRun
#1 /app/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application::run
#0 /app/bin/console(42): null
PHP 7.3.11 (cli)
ntl.default_locale => no value => no value
"name": "cron/cron",
"version": "1.4.1",
"name": "cron/cron-bundle",
"version": "2.2.0"
It happened twice during 15 days. But the command runs every minute. This is last 3 reports:
/app # bin/console doctrine:q:s "SELECT * FROM cron_report ORDER BY run_at DESC LIMIT 3"
/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Tools/Dumper.php:68:
array (size=3)
0 =>
array (size=6)
'id' => int 34246
'job_id' => int 1
'run_at' => string '2019-12-02 06:52:00' (length=19)
'run_time' => string '0.2821638584137' (length=15)
'exit_code' => int 0
'output' => string '0 messages found
' (length=17)
1 =>
array (size=6)
'id' => int 34245
'job_id' => int 1
'run_at' => string '2019-12-02 06:51:00' (length=19)
'run_time' => string '0.28854393959045' (length=16)
'exit_code' => int 0
'output' => string '0 messages found
' (length=17)
2 =>
array (size=6)
'id' => int 34244
'job_id' => int 1
'run_at' => string '2019-12-02 06:50:00' (length=19)
'run_time' => string '0.28462505340576' (length=16)
'exit_code' => int 0
'output' => string '0 messages found
' (length=17)
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.