Override arguments parameter repairs
authorBill Erickson <berick@esilibrary.com>
Fri, 1 Jun 2012 14:28:28 +0000 (10:28 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 1 Jun 2012 20:00:31 +0000 (16:00 -0400)
In some cases, the override arguments were passed as a paramater after
an @array or %hash argument.  In such cases, any params following are
clumped into the array/hash and the trailing parameters get no values.
Let's explicitly push the $oargs into the preceeding structures.

In the case of Circulate.pm:new, no $oargs argument is needed, as all keys
within the %args hash are tacked onto the circulator object.

Also, for consistency, this change affects one of the hold API calls by
moving $oargs into $params even when not strictly necessary.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>

Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm

index 88f7a73..f5c0f07 100644 (file)
@@ -191,13 +191,13 @@ __PACKAGE__->register_method(
 
 
 sub run_method {
-    my( $self, $conn, $auth, $args, $oargs ) = @_;
+    my( $self, $conn, $auth, $args ) = @_;
     translate_legacy_args($args);
-    $oargs = { all => 1 } unless defined $oargs;
+    $args->{override_args} = { all => 1 } unless defined $args->{override_args};
     my $api = $self->api_name;
 
     my $circulator = 
-        OpenILS::Application::Circ::Circulator->new($auth, %$args, $oargs);
+        OpenILS::Application::Circ::Circulator->new($auth, %$args);
 
     return circ_events($circulator) if $circulator->bail_out;
 
@@ -571,13 +571,12 @@ sub AUTOLOAD {
 
 
 sub new {
-    my( $class, $auth, %args, $oargs ) = @_;
+    my( $class, $auth, %args ) = @_;
     $class = ref($class) || $class;
     my $self = bless( {}, $class );
 
     $self->events([]);
     $self->editor(new_editor(xact => 1, authtoken => $auth));
-    $self->override_args($oargs);
 
     unless( $self->editor->checkauth ) {
         $self->bail_on_events($self->editor->event);
index 23f19a9..6e4f2b8 100644 (file)
@@ -2220,18 +2220,19 @@ All key/value pairs are passed on to do_possibility_checks.
 # FIXME: specify proper usage/interaction of selection_ou and pickup_lib
 
 sub check_title_hold {
-    my( $self, $client, $authtoken, $params, $oargs ) = @_;
+    my( $self, $client, $authtoken, $params ) = @_;
     my $e = new_editor(authtoken=>$authtoken);
     return $e->event unless $e->checkauth;
-    $oargs = {} unless defined $oargs;
+
+    my %params       = %$params;
+    my $depth        = $params{depth}        || 0;
+    my $selection_ou = $params{selection_ou} || $params{pickup_lib};
+    my $oargs        = $params{oargs}        || {};
 
     if($oargs->{events}) {
         @{$oargs->{events}} = grep { $e->allowed($_ . '.override', $e->requestor->ws_ou); } @{$oargs->{events}};
     }
 
-    my %params       = %$params;
-    my $depth        = $params{depth}        || 0;
-    my $selection_ou = $params{selection_ou} || $params{pickup_lib};
 
        my $patron = $e->retrieve_actor_user($params{patronid})
                or return $e->event;
@@ -2262,7 +2263,7 @@ sub check_title_hold {
         my $depth = $soft_boundary;
         while($depth >= $min_depth) {
             $logger->info("performing hold possibility check with soft boundary $depth");
-            @status = do_possibility_checks($e, $patron, $request_lib, $depth, %params, $oargs);
+            @status = do_possibility_checks($e, $patron, $request_lib, $depth, %params);
             if ($status[0]) {
                 $return_depth = $depth;
                 last;
@@ -2272,11 +2273,11 @@ sub check_title_hold {
     } elsif(defined $hard_boundary and $depth < $hard_boundary) {
         # there is no soft boundary, enforce the hard boundary if it exists
         $logger->info("performing hold possibility check with hard boundary $hard_boundary");
-        @status = do_possibility_checks($e, $patron, $request_lib, $hard_boundary, %params, $oargs);
+        @status = do_possibility_checks($e, $patron, $request_lib, $hard_boundary, %params);
     } else {
         # no boundaries defined, fall back to user specifed boundary or no boundary
         $logger->info("performing hold possibility check with no boundary");
-        @status = do_possibility_checks($e, $patron, $request_lib, $params{depth}, %params, $oargs);
+        @status = do_possibility_checks($e, $patron, $request_lib, $params{depth}, %params);
     }
 
     my $place_unfillable = 0;
@@ -2299,7 +2300,7 @@ sub check_title_hold {
 
 
 sub do_possibility_checks {
-    my($e, $patron, $request_lib, $depth, %params, $oargs) = @_;
+    my($e, $patron, $request_lib, $depth, %params) = @_;
 
     my $issuanceid   = $params{issuanceid}      || "";
     my $partid       = $params{partid}      || "";
@@ -2311,6 +2312,7 @@ sub do_possibility_checks {
     my $hold_type    = $params{hold_type}    || 'T';
     my $selection_ou = $params{selection_ou} || $pickup_lib;
     my $holdable_formats = $params{holdable_formats};
+    my $oargs        = $params{oargs}        || {};
 
 
        my $copy;