[Koha-patches] [PATCH] bug 5399: remove useless eval 'use C4::Foo'

Galen Charlton gmcharlt at gmail.com
Sat Nov 13 06:10:18 CET 2010


Also add a couple FIXMEs

Signed-off-by: Galen Charlton <gmcharlt at gmail.com>
---
 acqui/addorderiso2709.pl |    6 +-----
 acqui/basketgroup.pl     |    7 ++++---
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl
index 903d2db..25366b1 100755
--- a/acqui/addorderiso2709.pl
+++ b/acqui/addorderiso2709.pl
@@ -37,7 +37,7 @@ use C4::Biblio;
 use C4::Items;
 use C4::Koha qw/GetItemTypes/;
 use C4::Budgets qw/GetBudgets/;
-use C4::Acquisition qw/NewOrderItem/;
+use C4::Acquisition qw/NewOrderItem GetBasket/;
 use C4::Bookseller qw/GetBookSellerFromId/;
 
 my $input = new CGI;
@@ -145,8 +145,6 @@ if ($op eq ""){
               if ($orderinfo{'listprice'} =~ /^([\d\.,]*)/) {
                   $orderinfo{'listprice'} = $1;
                   $orderinfo{'listprice'} =~ s/,/\./;
-                  eval "use C4::Acquisition qw/GetBasket/;";
-                  eval "use C4::Bookseller qw/GetBookSellerFromId/;";
                   my $basket = GetBasket($orderinfo{basketno});
                   my $bookseller = GetBookSellerFromId($basket->{booksellerid});
                   my $gst = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
@@ -162,8 +160,6 @@ if ($op eq ""){
               if ($orderinfo{'listprice'} =~ /^([\d\.,]*)/) {
                   $orderinfo{'listprice'} = $1;
                   $orderinfo{'listprice'} =~ s/,/\./;
-                  eval "use C4::Acquisition qw/GetBasket/;";
-                  eval "use C4::Bookseller qw/GetBookSellerFromId/;";
                   my $basket = GetBasket($orderinfo{basketno});
                   my $bookseller = GetBookSellerFromId($basket->{booksellerid});
                   my $gst = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl
index 69de099..613bbf6 100755
--- a/acqui/basketgroup.pl
+++ b/acqui/basketgroup.pl
@@ -183,8 +183,9 @@ sub printbasketgrouppdf{
     my ($basketgroupid) = @_;
     
     my $pdfformat = C4::Context->preference("OrderPdfFormat");
-    eval "use $pdfformat" ;
-    eval "use C4::Branch";
+    eval "use $pdfformat" ; 
+    # FIXME consider what would happen if $pdfformat does not
+    # contain the name of a valid Perl module. Доверяй, но проверяй
     
     my $basketgroup = GetBasketgroup($basketgroupid);
     my $bookseller = GetBookSellerFromId($basketgroup->{'booksellerid'});
@@ -244,7 +245,7 @@ sub printbasketgrouppdf{
     );
     my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->{gstrate} || C4::Context->preference("gist")) || die "pdf generation failed";
     print $pdf;
-    exit;
+    exit; # FIXME bad form to exit out of a subroutine like this
 }
 
 my $op = $input->param('op');
-- 
1.7.0



More information about the Koha-patches mailing list