]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/common.pl
Endlose Rekursionen via call_sub vermeiden.
[mfinanz.git] / bin / mozilla / common.pl
index 17dac992e529617cb37beeb279f52212b372cb4c..c8ab34033caea6488b592ee774dab86a2ea33476 100644 (file)
@@ -9,6 +9,7 @@
 #
 ######################################################################
 
+use Carp;
 use SL::Common;
 use SL::DBUtils;
 use SL::Form;
@@ -76,6 +77,11 @@ sub select_part {
     $has_charge = 1;
     map { $_->{has_charge} = 1; } @parts;
   }
+  my $has_bestbefore = 0;
+  if (defined($parts[0]->{bestbefore})) {
+    $has_bestbefore = 1;
+    map { $_->{has_bestbefore} = 1; } @parts;
+  }
   my $has_ean = 0;
   if (defined($parts[0]->{ean})) {
     $has_ean = 1;
@@ -92,6 +98,7 @@ sub select_part {
                                      "nextsub"          => "select_part_internal",
                                      "callback_sub"     => $callback_sub,
                                      "has_charge"       => $has_charge,
+                                     "has_bestbefore"   => $has_bestbefore,
                                      "has_ean"          => $has_ean,
                                      "remap_parts_id"   => $remap_parts_id,
                                      "remap_partnumber" => $remap_partnumber });
@@ -502,6 +509,8 @@ sub show_history {
 
 # -------------------------------------------------------------------------
 
+my %_called_subs = ();
+
 sub call_sub {
   $main::lxdebug->enter_sub();
 
@@ -520,6 +529,9 @@ sub call_sub {
     $form->error(sprintf($locale->text("Attempt to call an undefined sub named '%s'"), $name));
   }
 
+  $_called_subs{$name}++;
+  confess "RECURSION DETECTION: call_sub($name) called " . $_called_subs{$name} . " time(s)" if $_called_subs{$name} > 10;
+
   {
     no strict "refs";
     &{ $name }(@_);