Skip to content

Commit

Permalink
Merge pull request #273 from ctfliblime/dbix_connector
Browse files Browse the repository at this point in the history
Convert to C4::Context $dbh handling to DBIx::Connector
  • Loading branch information
ctfliblime committed Dec 23, 2011
2 parents b76a548 + d431080 commit 2ab4d48
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 343 deletions.
1 change: 1 addition & 0 deletions Makefile.PL
Expand Up @@ -554,6 +554,7 @@ WriteMakefile(
'DBD::mysql' => 4.004,
'DBD::SQLite' => 0.33, # optional, used for offline circulation
'DBI' => 1.53,
'DBIx::Connector' => 0.47,
'Data::Dumper' => 2.121,
'Data::ICal' => 0.13,
'Date::Calc' => 5.4,
Expand Down
2 changes: 1 addition & 1 deletion cgi/circ/circulation.pl
Expand Up @@ -724,7 +724,7 @@ sub FormatFinesSummary {
if ($stickyduedate) {
$session->param( 'stickyduedate', $duedatespec );
}

$session->flush();

my ($picture, $dberror) = GetPatronImage($borrower->{'cardnumber'});
$template->param( picture => 1 ) if $picture;
Expand Down
2 changes: 1 addition & 1 deletion cgi/circ/returns.pl
Expand Up @@ -231,6 +231,7 @@ =head1 returns.pl
$dropboxmode = $session->param('circ_ci_dropboxmode');
$checkin_override_date = $session->param('circ_ci_backdate');
}
$session->flush();

if ($dotransfer && ($notransfer==0)){
# An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer
Expand Down Expand Up @@ -737,5 +738,4 @@ =head1 returns.pl

# actually print the page!
output_html_with_http_headers $query, $cookie, $template->output;
exit;
__END__
1 change: 1 addition & 0 deletions cgi/circ/selectbranchprinter.pl
Expand Up @@ -138,4 +138,5 @@
recycle_loop=> \@recycle_loop,
);

$session->flush();
output_html_with_http_headers $query, $cookie, $template->output;
1 change: 0 additions & 1 deletion cgi/opac/opac-addbybiblionumber.pl
Expand Up @@ -30,7 +30,6 @@
use C4::VirtualShelves qw/:DEFAULT GetRecentShelves RefreshShelvesSummary/;
use C4::Auth;
use C4::Output;
use C4::Auth qw/get_session/;
use C4::Debug;

#splits incoming biblionumber(s) to array and adds each to shelf.
Expand Down
85 changes: 0 additions & 85 deletions cgi/opac/opac-logout.pl

This file was deleted.

30 changes: 5 additions & 25 deletions cgi/tools/manage-marc-import.pl
Expand Up @@ -17,8 +17,7 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA

use strict;
use warnings;
use Koha;
no warnings qw(redefine);

# standard or CPAN modules used
Expand All @@ -27,7 +26,6 @@
use MARC::File::USMARC;

# Koha modules used
use Koha;
use C4::Context;
use C4::Auth;
use C4::Output;
Expand Down Expand Up @@ -228,16 +226,13 @@ sub commit_batch {
my ($template, $import_batch_id, $runinbackground, $sessionID) = @_;

my $job = undef;
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
my $callback = sub {};
if ($runinbackground) {
$job = put_in_background($import_batch_id, $sessionID);
$callback = progress_callback($job, $dbh);
$callback = progress_callback($job);
}
my ($num_added, $num_updated, $num_items_added, $num_items_errored, $num_ignored) =
BatchCommitBibRecords($import_batch_id, 50, $callback);
$dbh->commit();

my $results = {
did_commit => 1,
Expand All @@ -257,17 +252,14 @@ sub commit_batch {
sub revert_batch {
my ($template, $import_batch_id, $runinbackground, $sessionID) = @_;

my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
my $job = undef;
my $callback = sub {};
if ($runinbackground) {
$job = put_in_background($import_batch_id, $sessionID);
$callback = progress_callback($job, $dbh);
$callback = progress_callback($job);
}
my ($num_deleted, $num_errors, $num_reverted, $num_items_deleted, $num_ignored) =
BatchRevertBibRecords($import_batch_id, 50, $callback);
$dbh->commit();

my $results = {
did_revert => 1,
Expand All @@ -288,7 +280,6 @@ sub put_in_background {
my $import_batch_id = shift;
my $sessionID = shift;

my $dbh = C4::Context->dbh;
my $batch = GetImportBatch($import_batch_id);
my $job = C4::BackgroundJob->new($sessionID, $batch->{'file_name'}, $ENV{'SCRIPT_NAME'}, $batch->{'num_biblios'});
my $jobID = $job->id();
Expand All @@ -298,35 +289,24 @@ sub put_in_background {
# parent
# return job ID as JSON

# prevent parent exiting from
# destroying the kid's database handle
# FIXME: according to DBI doc, this may not work for Oracle
$dbh->{InactiveDestroy} = 1;

my $reply = CGI->new("");
print $reply->header(-type => 'text/html');
print $reply->header(-type => 'application/json');
print "{ jobID: '$jobID' }";
exit 0;
} elsif (defined $pid) {
# child
# close STDOUT to signal to Apache that
# we're now running in the background
close STDOUT;
} else {
# fork failed, so exit immediately
warn "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job";
exit 0;
die "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job";
}
return $job;
}

sub progress_callback {
my $job = shift;
my $dbh = shift;
return sub {
my $progress = shift;
$job->progress($progress);
$dbh->commit();
}
}

Expand Down

0 comments on commit 2ab4d48

Please sign in to comment.