Closed Jelle-S closed 1 year ago
You need to debug which timezone is used in that place: https://github.com/kimai/kimai/blob/main/src/Form/Type/TimePickerType.php#L62
This is not a general error, I just tried and it works without problems.
The error Unknown or bad timezone ()
means the timezone string is empty.
And I do not see how that is possible to happen.
Please create a screenshot of how your exactly create that field. Also show me a screenshot of "Doctor > PHP > date.timezone".
I was debugging it yesterday, and the model_timezone there says null
This is the field config:
And this is the default timezone:
From what I can see that option should default to the default timezone. Given that it is null, it must get overridden somewhere? But I can't seem to find where that would be.
Also show me a screenshot of "Doctor > PHP > date.timezone".
And please check what is in date_default_timezone_get()
Once we know how to reproduce it, it should be easy to fix.
That also returns "Europe/Brussels".
Changing https://github.com/kimai/kimai/blob/main/src/Form/Type/TimePickerType.php#L62 to
$now = new \DateTime('now', new \DateTimeZone($options['model_timezone'] ?? date_default_timezone_get()));
seems to fix it, but I don't think that is the right way to fix this, as there seems to be an underlying issue.
After some more debugging, I found that the culprint is https://github.com/kimai/kimai/blob/main/src/Form/Type/DateTimePickerType.php#L116-L117
When I change those null
values to date_default_timezone_get()
it is fixed... I'm not entirely sure of the inner workings of Symfony/Kimai... So I'm also not sure if that is the right place/way of fixing this issue?
Hahaha, because you said
we get a fatal error on the edit screen of an activity
I thought you get the error when you open the screen... I didn't try actually to save a date-time 🙈 Now I can reproduce it and yes, your proposed fix is correct. I'll add it to the next minor release.
Thanks for debugging 👍
I didn't get it when opening the create screen, correct. I got it on save, but also on editing an existing activity (on the edit screen, before save). Anyway, glad it'll get fixed! Thanks!
When adding a Date and Time field to an activity, we get a fatal error on the edit screen of an activity, with following message:
When I remove the field again, the error is gone too.