freeside/FS/FS Record.pm,1.88,1.89
ivan
ivan at pouncequick.420.am
Sat Jul 10 06:21:54 PDT 2004
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory pouncequick:/tmp/cvs-serv16945
Modified Files:
Record.pm
Log Message:
fix FS::Record::qsearch to (hopefully) work as before and cluck loudly when the FS::tablename class isn't loaded, rather than throw exceptions
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- Record.pm 6 Jul 2004 19:10:13 -0000 1.88
+++ Record.pm 10 Jul 2004 13:21:51 -0000 1.89
@@ -210,7 +210,13 @@
my $pkey = $dbdef_table->primary_key;
my @real_fields = grep exists($record->{$_}), real_fields($table);
- my @virtual_fields = grep exists($record->{$_}), "FS::$table"->virtual_fields;
+ my @virtual_fields;
+ if ( eval 'scalar(@FS::'. $table. '::ISA);' ) {
+ @virtual_fields = grep exists($record->{$_}), "FS::$table"->virtual_fields;
+ } else {
+ cluck "warning: FS::$table not loaded; virtual fields not searchable";
+ @virtual_fields = ();
+ }
my $statement = "SELECT $select FROM $stable";
if ( @real_fields or @virtual_fields ) {
@@ -328,10 +334,15 @@
$sth->execute or croak "Error executing \"$statement\": ". $sth->errstr;
+ if ( eval 'scalar(@FS::'. $table. '::ISA);' ) {
+ @virtual_fields = "FS::$table"->virtual_fields;
+ } else {
+ cluck "warning: FS::$table not loaded; virtual fields not returned either";
+ @virtual_fields = ();
+ }
+
my %result;
tie %result, "Tie::IxHash";
- @virtual_fields = "FS::$table"->virtual_fields;
-
my @stuff = @{ $sth->fetchall_arrayref( {} ) };
if($pkey) {
%result = map { $_->{$pkey}, $_ } @stuff;
@@ -340,6 +351,7 @@
}
$sth->finish;
+
if ( keys(%result) and @virtual_fields ) {
$statement =
"SELECT virtual_field.recnum, part_virtual_field.name, ".
More information about the freeside-commits
mailing list