fix multi-database installs, while hopefully keeping performance improvement
authorivan <ivan>
Fri, 28 Jun 2002 08:23:44 +0000 (08:23 +0000)
committerivan <ivan>
Fri, 28 Jun 2002 08:23:44 +0000 (08:23 +0000)
FS/FS/Record.pm
FS/FS/UID.pm

index f7c3a41..7d5ff05 100644 (file)
@@ -2,7 +2,7 @@ package FS::Record;
 
 use strict;
 use vars qw( $dbdef_file $dbdef $setup_hack $AUTOLOAD @ISA @EXPORT_OK $DEBUG
-             $me );
+             $me %dbdef_cache );
 use subs qw(reload_dbdef);
 use Exporter;
 use Carp qw(carp cluck croak confess);
@@ -1130,8 +1130,10 @@ I<$FS::Record::setup_hack> is true.  Returns a DBIx::DBSchema object.
 
 sub reload_dbdef {
   my $file = shift || $dbdef_file;
-  $dbdef = load DBIx::DBSchema $file
-    or die "can't load database schema from $file";
+  $dbdef = exists $dbdef_cache{$file}
+    ? $dbdef_cache{$file}
+    : $dbdef_cache{$file} = DBIx::DBSchema->load( $file )
+                              or die "can't load database schema from $file";
 }
 
 =item dbdef
index 87830cb..b1e590f 100644 (file)
@@ -92,7 +92,7 @@ sub forksuidsetup {
 
   foreach ( keys %callback ) {
     &{$callback{$_}};
-    delete $callback{$_}; #run once
+    # breaks multi-database installs # delete $callback{$_}; #run once
   }
 
   $dbh;
@@ -256,7 +256,7 @@ coderef into the hash %FS::UID::callback :
 
 =head1 VERSION
 
-$Id: UID.pm,v 1.15 2002-06-14 09:19:33 ivan Exp $
+$Id: UID.pm,v 1.16 2002-06-28 08:23:44 ivan Exp $
 
 =head1 BUGS