fetch bookbags inside xact to avoid replication delays, which can occur directly...
authorberick <berick@esilibrary.com>
Thu, 14 Apr 2011 19:04:23 +0000 (15:04 -0400)
committerberick <berick@esilibrary.com>
Thu, 14 Apr 2011 19:23:53 +0000 (15:23 -0400)
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm

index 67920e3..035ff3a 100644 (file)
@@ -513,21 +513,31 @@ sub load_myopac_bookbags {
     my $e = $self->editor;
     my $ctx = $self->ctx;
 
+    $e->xact_begin; # replication...
+
     my $rv = $self->load_mylist;
-    return $rv if $rv ne Apache2::Const::OK;
+    unless($rv eq Apache2::Const::OK) {
+        $e->rollback;
+        return $rv;
+    }
 
     my $args = {
         order_by => {cbreb => 'name'},
         limit => $self->cgi->param('limit') || 10,
-        offset => $self->cgi->param('limit') || 0
+        offset => $self->cgi->param('offset') || 0
     };
 
     $ctx->{bookbags} = $e->search_container_biblio_record_entry_bucket([
         {owner => $self->editor->requestor->id, btype => 'bookbag'},
         # XXX what to do about the possibility of really large bookbags here?
         {"flesh" => 1, "flesh_fields" => {"cbreb" => ["items"]}, %$args}
-    ]) or return $e->die_event;
+    ]);
 
+    if(!$ctx->{bookbags}) {
+        $e->rollback;
+        return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
+    }
+    
     # get unique record IDs
     my %rec_ids = ();
     foreach my $bbag (@{$ctx->{bookbags}}) {
@@ -540,6 +550,7 @@ sub load_myopac_bookbags {
 
     $ctx->{bookbags_marc_xml} = $self->fetch_marc_xml_by_id([keys %rec_ids]);
 
+    $e->rollback;
     return Apache2::Const::OK;
 }