bug: DateTime::TimeZone::Floating and STORABLE_attach

[email protected] (Kostas Chatzikokolakis)
Newsgroups perl.datetime
Message-ID <[email protected]>
Hello,

I'd like to report a bug: thawing a freezed DateTime object with
floating timezone doesn't work. It can be reproduced by:

  my $dt = DateTime->now(time_zone => "floating");
  print Dumper( thaw(freeze($dt))->{tz} );

The timezone of the thawed object is an empty blessed hashref, without
name or offset. Note that this only happens with DateTime objects,
thawing a DateTime::TimeZone::Floating object directly works!

The problem is caused by STORABLE_attach. Removing it solves the problem
(without breaking any tests).

Then I found the following in DateTime::TimeZone's Changelog.
  0.54     2006-10-25
- Got rid of the STORABLE_attach methods. This was causing bugs when
  trying to freeze/thaw a DateTime.pm object, and I realized that
  because of how the DT::TimeZone internals work, there's not much
  gained by using STORABLE_attach instead of STORABLE_freeze. Even
  with STORABLE_freeze, the core data structures for a timezone are
  still shared.

Indeed the ::Floating package is the only one containing a
STORABLE_attach method, it looks like it was forgotten there.

Cheers,
Kostas
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.