Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not nullable date and time fields cannot be set on exactly 1970-01-01 00:00:00 via (int)0 as that loosely evaluates to false in Propel\Runtime\Util\PropelDateTime #2010

Open
hsegnitz opened this issue Jun 28, 2024 · 0 comments · May be fixed by #2011

Comments

@hsegnitz
Copy link
Contributor

The offending code:

    public static function newInstance($value, ?DateTimeZone $timeZone = null, string $dateTimeClass = 'DateTime')
    {
        if ($value instanceof DateTimeInterface) {
            return $value;
        }
        **if (!$value) {**
            // '' is seen as NULL for temporal objects
            // because DateTime('') == DateTime('now') -- which is unexpected
            return null;
        }

It should be rather

if ($value === false || $value === null || $value === '') {
    ....
}

PR incoming when I figure out running the tests locally ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant