X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSerialize%2FStorable.pm;h=7cc121816a09aa85c5b6ba694465a4472688f571;hb=db79c254cc39865c4fb5a58b2ee63f62f9f0866f;hp=7ccd2b0f52edb3928f3bdf5dc0da21dde115d441;hpb=9b83fccd091065fcebbb6fb6fb7bf2c2da38ffe2;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Serialize/Storable.pm b/lib/DBIx/Class/Serialize/Storable.pm index 7ccd2b0..7cc1218 100644 --- a/lib/DBIx/Class/Serialize/Storable.pm +++ b/lib/DBIx/Class/Serialize/Storable.pm @@ -4,17 +4,27 @@ use warnings; use Storable; sub STORABLE_freeze { - my ($self,$cloning) = @_; + my ($self, $cloning) = @_; my $to_serialize = { %$self }; + + # The source is either derived from _source_handle or is + # reattached in the thaw handler below delete $to_serialize->{result_source}; + + # Dynamic values, easy to recalculate + delete $to_serialize->{$_} for qw/related_resultsets _inflated_column/; + return (Storable::freeze($to_serialize)); } sub STORABLE_thaw { - my ($self,$cloning,$serialized) = @_; + my ($self, $cloning, $serialized) = @_; + %$self = %{ Storable::thaw($serialized) }; + + # if the handle went missing somehow, reattach $self->result_source($self->result_source_instance) - if $self->can('result_source_instance'); + if !$self->_source_handle && $self->can('result_source_instance'); } 1;