TPac; Fetch authoritative user object in my-account
authorBill Erickson <berick@esilibrary.com>
Wed, 19 Oct 2011 20:53:44 +0000 (16:53 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 19 Oct 2011 20:59:45 +0000 (16:59 -0400)
Since user data changes in my-account, any time we fetch the fleshed
user object, fetch it within a transaction to avoid retrieval from a
(potentially lagging) DB replica.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm

index a1c2de4..a532bff 100644 (file)
@@ -15,6 +15,11 @@ my $U = 'OpenILS::Application::AppUtils';
 sub prepare_extended_user_info {
     my $self = shift;
     my @extra_flesh = @_;
+    my $e = $self->editor;
+
+    # are we already in a transaction?
+    my $local_xact = !$e->{xact_id}; 
+    $e->xact_begin if $local_xact;
 
     $self->ctx->{user} = $self->editor->retrieve_actor_user([
         $self->ctx->{user}->id,
@@ -25,7 +30,12 @@ sub prepare_extended_user_info {
                 # ...
             }
         }
-    ]) or return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
+    ]);
+
+    $e->rollback if $local_xact;
+
+    return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR 
+        unless $self->ctx->{user};
 
     return;
 }