optimize customer list (fix option caching in 3.x), RT#20173
authorIvan Kohler <ivan@freeside.biz>
Thu, 24 Mar 2016 02:19:36 +0000 (19:19 -0700)
committerIvan Kohler <ivan@freeside.biz>
Thu, 24 Mar 2016 02:19:36 +0000 (19:19 -0700)
FS/FS/part_pkg.pm
FS/FS/part_pkg/flat.pm

index 45bdc62..8f00304 100644 (file)
@@ -1416,9 +1416,8 @@ sub option {
   my( $self, $opt, $ornull ) = @_;
 
   #cache: was pulled up in the original part_pkg query
-  if ( $opt =~ /^(setup|recur)_fee$/ && defined($self->hashref->{"_$opt"}) ) {
-    return $self->hashref->{"_$opt"};
-  }
+  return $self->hashref->{"_opt_$opt"}
+    if exists $self->hashref->{"_opt_$opt"};
 
   cluck "$self -> option: searching for $opt" if $DEBUG;
   my $part_pkg_option =
index 04d761b..7b5a3f6 100644 (file)
@@ -136,11 +136,7 @@ sub calc_setup {
 
 sub base_setup {
   my($self, $cust_pkg, $sdate, $details ) = @_;
-  ( exists( $self->{'Hash'}{'_opt_setup_fee'} )
-      ? $self->{'Hash'}{'_opt_setup_fee'}
-      : $self->option('setup_fee', 1) 
-  )
-    || 0;
+  $self->option('setup_fee', 1) || 0;
 }
 
 sub calc_recur {
@@ -193,11 +189,7 @@ sub cutoff_day {
 
 sub base_recur {
   my($self, $cust_pkg, $sdate) = @_;
-  ( exists( $self->{'Hash'}{'_opt_recur_fee'} )
-      ? $self->{'Hash'}{'_opt_recur_fee'}
-      : $self->option('recur_fee', 1) 
-  )
-    || 0;
+  $self->option('recur_fee', 1) || 0;
 }
 
 sub base_recur_permonth {