Skip to content

Extreme Future DateTimeImmutable cause exceptions #7307

@KDederichs

Description

@KDederichs

Bug Report

Someone entered 185450-01-01 00:00:00 into a DateTimeImmutable field that's persisted to Postgres.
It persists just fine but when you try to read it, it'll explode the code.

Q A
Version 3.6.1
Previous Version if the bug is a regression x.y.z

Summary

Stack trace of the above mentioned behavior

    "@context": "/contexts/Error",\n
    "@id": "/errors/500",\n
    "@type": "Error",\n
    "title": "An error occurred",\n
    "detail": "Could not convert database value \"185450-01-01 00:00:00\" to Doctrine Type Doctrine\\DBAL\\Types\\DateTimeImmutableType. Expected format \"Y-m-d H:i:s\".",\n
    "status": 500,\n
    "type": "/errors/500",\n
    "description": "Could not convert database value \"185450-01-01 00:00:00\" to Doctrine Type Doctrine\\DBAL\\Types\\DateTimeImmutableType. Expected format \"Y-m-d H:i:s\".",\n
    "trace": [\n
        {\n
            "file": "/app/vendor/doctrine/dbal/src/Types/DateTimeImmutableType.php",\n
            "line": 72,\n
            "function": "new",\n
            "class": "Doctrine\\DBAL\\Types\\Exception\\InvalidFormat",\n
            "type": "::"\n
        },\n
        {\n
            "file": "/app/vendor/doctrine/orm/src/Internal/Hydration/AbstractHydrator.php",\n
            "line": 341,\n
            "function": "convertToPHPValue",\n
            "class": "Doctrine\\DBAL\\Types\\DateTimeImmutableType",\n
            "type": "->"\n
        },\n
        {\n
            "file": "/app/vendor/doctrine/orm/src/Internal/Hydration/ObjectHydrator.php",\n
            "line": 327,\n
            "function": "gatherRowData",\n
            "class": "Doctrine\\ORM\\Internal\\Hydration\\AbstractHydrator",\n
            "type": "->"\n
        },\n
        {\n

Current behavior

It writes to the DB but doesn't read.

Expected behavior

It should be consistent.
Either it should already fail while writing or be able to read the value.

How to reproduce

Commit the date 185450-01-01 00:00:00 to a DateTimeImmutable field and try to read the entity.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions