In DBIx::Class::Schema there was this change from .08123 to .08124:

-      $target_class->result_source_instance($source)
-        if $target_class->can('result_source_instance');
+      if ($target_class->can('result_source_instance')) {
+
+        # since the newly created classes are registered only with
+        # the instance of $schema, it should be safe to weaken
+        # the ref (it will GC when $schema is destroyed)
+        $target_class->result_source_instance($source);
+        weaken ${"${target_class}::__cag_result_source_instance"};
+      }

With that weaken I started getting warnings when thawing using Storable's
thaw (not using $schema->thaw) because schema was not found.  The issue is
this bit of code in DBIx::Class::ResultSourceHandle:

 sub STORABLE_thaw {
    my ($self, $cloning, $ice) = @_;
    %$self = %{ Storable::thaw($ice) };

    my $class = delete $self->{_frozen_from_class};
    if( $thaw_schema ) {
        $self->{schema} = $thaw_schema;
    }
    else {
        *my $rs = $class->result_source_instance;*
*        $self->{schema} = $rs->schema if $rs;*
    }

    carp "Unable to restore schema. Look at 'freeze' and 'thaw' methods in
DBIx::Class::Schema."
        unless $self->{schema};
}


With .08124 $rs is true above, but $rs->schema is undefined with the weaken.
 With .08124 (without the weaken) $rs->schema returns a schema object.

Is that expected?

To be honest, I'm surprised that thawing directly with Storable was working
before because I was not calling $schema->thaw or
setting $DBIx::Class::ResultSourceHandle::thaw_schema = $schema. (The DBIx
object was part of a larger structure saved in Memcached.) So, I'm not clear
if it was just lucky that it was working before or if this is an unintended
side-effect from adding that weaken.



-- 
Bill Moseley
[email protected]
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to