[Koha-patches] [PATCH] Bug 8442 - labels creator fixes for plack

Dobrica Pavlinusic dpavlin at rot13.org
Fri Jul 20 14:18:50 CEST 2012


- remove all exit(1) and replace them with __END__ which benefits CGI
- insert correct =cut markers at end of POD (required for CGI::Compile
  under plack to correctly parse source code and exeute it)
- scope variables with our which are used inside sub for plack
---
 labels/label-create-csv.pl |    5 ++---
 labels/label-create-pdf.pl |    6 +++---
 labels/label-create-xml.pl |    4 ++--
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/labels/label-create-csv.pl b/labels/label-create-csv.pl
index 1229c0a..1b0c02c 100755
--- a/labels/label-create-csv.pl
+++ b/labels/label-create-csv.pl
@@ -72,7 +72,6 @@ else {
 
 my $csv = Text::CSV_XS->new();
 
-CSV_ITEMS:
 foreach my $item (@$items) {
     my $label = C4::Labels::Label->new(
                                     batch_id            => $batch_id,
@@ -85,11 +84,10 @@ foreach my $item (@$items) {
     }
     else {
         warn sprintf('Text::CSV_XS->combine() returned the following error: %s', $csv->error_input);
-        next CSV_ITEMS;
     }
 }
 
-exit(1);
+__END__
 
 =head1 NAME
 
@@ -122,3 +120,4 @@ Fifth Floor, Boston, MA 02110-1301 USA.
 Koha is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
+=cut
diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl
index 3001c14..3d7ff1f 100755
--- a/labels/label-create-pdf.pl
+++ b/labels/label-create-pdf.pl
@@ -58,9 +58,9 @@ print $cgi->header( -type       => 'application/pdf',
                     -attachment => "$pdf_file.pdf",
                   );
 
-my $pdf = C4::Creators::PDF->new(InitVars => 0);
+our $pdf = C4::Creators::PDF->new(InitVars => 0);
 my $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
-my $template = C4::Labels::Template->retrieve(template_id => $template_id, profile_id => 1);
+our $template = C4::Labels::Template->retrieve(template_id => $template_id, profile_id => 1);
 my $layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
 
 sub _calc_next_label_pos {
@@ -205,7 +205,7 @@ foreach my $item (@{$items}) {
 
 $pdf->End();
 
-exit(1);
+__END__
 
 =head1 NAME
 
diff --git a/labels/label-create-xml.pl b/labels/label-create-xml.pl
index 6604dc4..5e62ef8 100755
--- a/labels/label-create-xml.pl
+++ b/labels/label-create-xml.pl
@@ -74,7 +74,6 @@ my $xml_data = {'label' => []};
 
 my $item_count = 0;
 
-XML_ITEMS:
 foreach my $item (@$items) {
     push(@{$xml_data->{'label'}}, {'item_number' => $item->{'item_number'}});
     my $label = C4::Labels::Label->new(
@@ -98,7 +97,7 @@ my $xml_out = $xml->XMLout($xml_data);
 #die "XML OUT:\n" . Dumper($xml_out);
 print $xml_out;
 
-exit(1);
+__END__
 
 =head1 NAME
 
@@ -132,3 +131,4 @@ Fifth Floor, Boston, MA 02110-1301 USA.
 Koha is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
+=cut
-- 
1.7.2.5



More information about the Koha-patches mailing list