I have this old method in Handel that clones a storage class instance by first dereferencing the DBIC schema/DBI handle to keep Clone from bitching, calling Clone::clone, then stuffing the schema back in the original object.
sub clone {
my $self = shift;
Handel::Exception::Storage->throw(
-details => translate('NOT_CLASS_METHOD')
) unless blessed($self); ## no critic
# a hack indeed. clone barfs on some DBI inards, so lets move out the
# schema instance while we clone and put it back
if ($self->_schema_instance) {
my $schema = $self->_schema_instance;
$self->_schema_instance(undef);
my $clone = Clone::clone($self);
$self->_schema_instance($schema);
return $clone;
} else {
return $self->SUPER::clone;
};
};
In 5.8, this works, and $clone->{'connection_info'}->[...] is copied from the original.
In 5.10, $clone->{'connection_info'}->[] is empty.
Just for giggles, using Storable::dclone works just dandily, but I didn't use it in 5.8 because for one line of code, it's a pain in the ass as a prereq, esp on windows sometimes.
ANyone else have isues with Clone under 5.10?
Storable prereq (Score:2)
This would be the
Storablethat has been in core as of 5.8.0? And built and installed by default? So what's the problem with making it a prerequisite?Re: (Score:2)
Can't speak for Chris, but for me it is horribly broken if at any time you upgrade. Anything made with a specific version of Storable will ONLY work with that version of Storable. The data file also breaks between different OSs even with the same version. In a previous project I ended up moving to XML because it actually was persistent!
It may have changed since, but these days I avoid it wherever possible.
Re: (Score:2)
The default file format is architecture specific, for speed. If you want to move things between systems (or
perlconfigurations) you wantnstoreornfreeze.As to between versions - yes, there was a bug in the version checking code, based on the intent. It used to (wrongly) insist that the major and minor versions of the file were identical, and as the minor version had often been bumped, that meant problems. Some time ago (I forget w
Re: (Score:1)
This is also the same Storable that constantly dies of gets wrong cloning with "Can't store CODE items" errors. Another problem Clone::clone never has.