Neuter Class::C3::reinitialize() around the schema reloading.
Dagfinn Ilmari Mannsåker [Sun, 1 Jun 2008 00:29:08 +0000 (00:29 +0000)]
We're not changing any inheritance here, and this is equivalent to what
the old code did around _make_src_class().

lib/DBIx/Class/Schema/Loader/Base.pm

index a78ba9e..25ae429 100644 (file)
@@ -412,13 +412,19 @@ sub _reload_classes {
     for my $table (@tables) {
         my $moniker = $self->monikers->{$table};
         my $class = $self->classes->{$table};
-
-        if ( Class::Unload->unload( $class ) ) {
-            my $resultset_class = ref $self->schema->resultset($moniker);
-            Class::Unload->unload( $resultset_class )
-                  if $resultset_class ne 'DBIx::Class::ResultSet';
+        
+        {
+            no warnings 'redefine';
+            local *Class::C3::reinitialize = sub {};
+            use warnings;
+
+            if ( Class::Unload->unload( $class ) ) {
+                my $resultset_class = ref $self->schema->resultset($moniker);
+                Class::Unload->unload( $resultset_class )
+                      if $resultset_class ne 'DBIx::Class::ResultSet';
+            }
+            $class->require or die "Can't load $class: $@";
         }
-        $class->require or die "Can't load $class: $@";
 
         $self->schema_class->register_class($moniker, $class);
         $self->schema->register_class($moniker, $class)