Lines 117-123
sub GetLetters {
Link Here
|
117 |
return \%letters; |
117 |
return \%letters; |
118 |
} |
118 |
} |
119 |
|
119 |
|
120 |
my %letter; |
120 |
# FIXME: using our here means that a Plack server will need to be |
|
|
121 |
# restarted fairly regularly when working with this routine. |
122 |
# A better option would be to use Koha::Cache and use a cache |
123 |
# that actually works in a persistent environment, but as a |
124 |
# short-term fix, our will work. |
125 |
our %letter; |
121 |
sub getletter { |
126 |
sub getletter { |
122 |
my ( $module, $code, $branchcode ) = @_; |
127 |
my ( $module, $code, $branchcode ) = @_; |
123 |
|
128 |
|
Lines 551-565
sub _substitute_tables {
Link Here
|
551 |
} |
556 |
} |
552 |
} |
557 |
} |
553 |
|
558 |
|
554 |
my %handles = (); |
|
|
555 |
sub _parseletter_sth { |
559 |
sub _parseletter_sth { |
556 |
my $table = shift; |
560 |
my $table = shift; |
|
|
561 |
my $sth; |
557 |
unless ($table) { |
562 |
unless ($table) { |
558 |
carp "ERROR: _parseletter_sth() called without argument (table)"; |
563 |
carp "ERROR: _parseletter_sth() called without argument (table)"; |
559 |
return; |
564 |
return; |
560 |
} |
565 |
} |
561 |
# check cache first |
566 |
# NOTE: we used to check whether we had a statement handle cached in |
562 |
(defined $handles{$table}) and return $handles{$table}; |
567 |
# a %handles module-level variable. This was a dumb move and |
|
|
568 |
# broke things for the rest of us. prepare_cached is a better |
569 |
# way to cache statement handles anyway. |
563 |
my $query = |
570 |
my $query = |
564 |
($table eq 'biblio' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : |
571 |
($table eq 'biblio' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : |
565 |
($table eq 'biblioitems' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : |
572 |
($table eq 'biblioitems' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : |
Lines 579-589
sub _parseletter_sth {
Link Here
|
579 |
warn "ERROR: No _parseletter_sth query for table '$table'"; |
586 |
warn "ERROR: No _parseletter_sth query for table '$table'"; |
580 |
return; # nothing to get |
587 |
return; # nothing to get |
581 |
} |
588 |
} |
582 |
unless ($handles{$table} = C4::Context->dbh->prepare($query)) { |
589 |
unless ($sth = C4::Context->dbh->prepare_cached($query)) { |
583 |
warn "ERROR: Failed to prepare query: '$query'"; |
590 |
warn "ERROR: Failed to prepare query: '$query'"; |
584 |
return; |
591 |
return; |
585 |
} |
592 |
} |
586 |
return $handles{$table}; # now cache is populated for that $table |
593 |
return $sth; # now cache is populated for that $table |
587 |
} |
594 |
} |
588 |
|
595 |
|
589 |
=head2 _parseletter($letter, $table, $values) |
596 |
=head2 _parseletter($letter, $table, $values) |
Lines 597-603
sub _parseletter_sth {
Link Here
|
597 |
|
604 |
|
598 |
=cut |
605 |
=cut |
599 |
|
606 |
|
600 |
my %columns = (); |
|
|
601 |
sub _parseletter { |
607 |
sub _parseletter { |
602 |
my ( $letter, $table, $values ) = @_; |
608 |
my ( $letter, $table, $values ) = @_; |
603 |
|
609 |
|
604 |
- |
|
|