From: Peter Rabbitson Date: Sat, 30 Oct 2010 09:36:47 +0000 (+0200) Subject: Switch all Storable serialization calls from freeze() to nfreeze() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=26148d36e66d7f7c67863cea8d6501739b765692;hp=49bceca3dbc42bc27720f777f336619bd2792943;p=dbsrgits%2FDBIx-Class-Historic.git Switch all Storable serialization calls from freeze() to nfreeze() ovid++ for researching this: http://blogs.perl.org/users/ovid/2010/10/storable-freeze-versus-nfreeze.html --- diff --git a/Changes b/Changes index fb4b43d..588d365 100644 --- a/Changes +++ b/Changes @@ -18,6 +18,8 @@ Revision history for DBIx::Class regression of inserts into a Postgres / ::Replicated combination - Missing dependency check in t/60core.t (RT#62635) - Fix regressions in IC::DT registration logic + - Switch all serialization to use Storable::nfreeze for portable + architecture independent ice 0.08124 2010-10-28 14:23 (UTC) * New Features / Changes diff --git a/lib/DBIx/Class/Manual/Component.pod b/lib/DBIx/Class/Manual/Component.pod index 89c3a50..ac94adb 100644 --- a/lib/DBIx/Class/Manual/Component.pod +++ b/lib/DBIx/Class/Manual/Component.pod @@ -82,7 +82,7 @@ Check out the L docs for more information about inheritance. These components provide extra functionality beyond basic functionality that you can't live without. -L - Hooks for Storable freeze/thaw. +L - Hooks for Storable nfreeze/thaw. L - Class::DBI Compatibility layer. diff --git a/lib/DBIx/Class/ResultSourceHandle.pm b/lib/DBIx/Class/ResultSourceHandle.pm index cd5c45c..e39bfbc 100644 --- a/lib/DBIx/Class/ResultSourceHandle.pm +++ b/lib/DBIx/Class/ResultSourceHandle.pm @@ -81,7 +81,7 @@ sub STORABLE_freeze { delete $to_serialize->{schema}; $to_serialize->{_frozen_from_class} = $self->schema->class($self->source_moniker); - return (Storable::freeze($to_serialize)); + return (Storable::nfreeze($to_serialize)); } =head2 STORABLE_thaw diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 348edeb..3c78930 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -1201,13 +1201,13 @@ sub thaw { =head2 freeze -This doesn't actually do anything more than call L, it is just +This doesn't actually do anything more than call L, it is just provided here for symmetry. =cut sub freeze { - return Storable::freeze($_[1]); + return Storable::nfreeze($_[1]); } =head2 dclone diff --git a/lib/DBIx/Class/Serialize/Storable.pm b/lib/DBIx/Class/Serialize/Storable.pm index 7cc1218..9ba4f6d 100644 --- a/lib/DBIx/Class/Serialize/Storable.pm +++ b/lib/DBIx/Class/Serialize/Storable.pm @@ -14,7 +14,7 @@ sub STORABLE_freeze { # Dynamic values, easy to recalculate delete $to_serialize->{$_} for qw/related_resultsets _inflated_column/; - return (Storable::freeze($to_serialize)); + return (Storable::nfreeze($to_serialize)); } sub STORABLE_thaw { @@ -33,7 +33,7 @@ __END__ =head1 NAME - DBIx::Class::Serialize::Storable - hooks for Storable freeze/thaw + DBIx::Class::Serialize::Storable - hooks for Storable nfreeze/thaw =head1 SYNOPSIS diff --git a/t/84serialize.t b/t/84serialize.t index 99449d4..c048151 100644 --- a/t/84serialize.t +++ b/t/84serialize.t @@ -1,11 +1,11 @@ use strict; -use warnings; +use warnings; use Test::More; use Test::Exception; use lib qw(t/lib); use DBICTest; -use Storable qw(dclone freeze thaw); +use Storable qw(dclone freeze nfreeze thaw); my $schema = DBICTest->init_schema(); @@ -19,6 +19,9 @@ my %stores = ( "freeze/thaw_func" => sub { thaw(freeze($_[0])); }, + "nfreeze/thaw_func" => sub { + thaw(nfreeze($_[0])); + }, ); plan tests => (11 * keys %stores); @@ -28,7 +31,7 @@ for my $name (keys %stores) { my $copy; my $artist = $schema->resultset('Artist')->find(1); - + # Test that the procedural versions will work if there's a registered # schema as with CDBICompat objects and that the methods work # without.