From 703408cdb026cdec22cd3e1d332d5c92a83ea677 Mon Sep 17 00:00:00 2001
From: gmc <gmc@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Mon, 1 Nov 2010 23:22:53 +0000
Subject: [PATCH] yet another replication race condition fix

Fixes problems that can occur when creating a lineitem
from an existing bib in the catalog; adds an authoritative
version of open-ils.acq.lineitem.retrieve.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>


git-svn-id: svn://svn.open-ils.org/ILS/trunk@18565 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm | 1 +
 Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm   | 6 ++++--
 Open-ILS/web/js/ui/default/acq/common/li_table.js         | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
index 0903e31b09..3f3940b7a3 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
@@ -69,6 +69,7 @@ sub create_lineitem {
 __PACKAGE__->register_method(
     method    => 'retrieve_lineitem',
     api_name  => 'open-ils.acq.lineitem.retrieve',
+    authoritative => 1,
     signature => {
         desc   => 'Retrieves a lineitem',
         params => [
diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm
index 33f40c9d87..b6f267c903 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Search.pm
@@ -602,10 +602,12 @@ sub bib_search {
 
     $logger->info("created @li_ids new lineitems for picklist $picklist");
 
-    # new editor, no transaction needed this time
-    $e = new_editor("authtoken" => $auth) or return $e->die_event;
+    # new editor, but still using transaction to ensure correct retrieval
+    # in a replicated setup
+    $e = new_editor("authtoken" => $auth, xact => 1) or return $e->die_event;
     return $e->die_event unless $e->checkauth;
     $conn->respond($RETRIEVERS{"lineitem"}->($e, $_, $opts)) foreach @li_ids;
+    $e->rollback;
     $e->disconnect;
 
     undef;
diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js
index 3f58eecaa7..d12d09fac0 100644
--- a/Open-ILS/web/js/ui/default/acq/common/li_table.js
+++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js
@@ -794,7 +794,7 @@ function AcqLiTable() {
             return handler(li);
         
         fieldmapper.standardRequest(
-            ['open-ils.acq', 'open-ils.acq.lineitem.retrieve'],
+            ['open-ils.acq', 'open-ils.acq.lineitem.retrieve.authoritative'],
             {   async: true,
 
                 params: [self.authtoken, liId, {
-- 
2.11.0