audit-stash icon indicating copy to clipboard operation
audit-stash copied to clipboard

String datetime changes may break custom DateTimeType implementations

Open cschomburg opened this issue 4 years ago • 1 comments

In our application we are using a custom Cake\Database\Type\DateTimeType::marshal() that extends the default CakePHP database type. Our implementation basically interprets strings with no timezone information as being in the user's local timezone.

Upgrading to audit-stash 3.0.2 causes timezone issues with the created timestamp in our application. Previously we received a \DateTime object which we handled correctly. Now, due to the changes in #48, we only receive a string Y-m-d H:i:s with no timezone information given, and our application interprets this as the wrong timezone.

I'm not sure if this is expected behavior and our application is simply at fault for interpreting them differently than UTC. But in any case, this looks like a behavior change which we cannot easily work around due to the tz information loss.

Modifying the type check in #48 to handle inherited classes would solve our issue, but I don't know if this breaks the original authors intent:

if (!is_subclass_of(Type::getMap('datetime'), DateTimeType::class)) {

Or maybe this should be configurable behavior. Any ideas on how to proceed here?

cschomburg avatar Nov 19 '20 17:11 cschomburg

Configurable sounds best for the moment A PR here would be welcome.

dereuromark avatar Jan 10 '24 10:01 dereuromark