TPAC: Avoid hold placement problems à la 80d5c4a4
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 1 Feb 2012 21:58:45 +0000 (16:58 -0500)
committerThomas Berezansky <tsbere@mvlc.org>
Thu, 2 Feb 2012 13:49:47 +0000 (08:49 -0500)
A commit written in October and merged quickly (80d5c4a4) was designed
to avoid problems with a middle layer method that sometimes returns hash
refs and sometimes returns array refs.

A commit written in September but not merged until January (a663dfed)
affected neighboring code, but was not aware of the other code to dance
around hash refs and array refs (just read the commit messages of each
to see what I mean, with attention to the changes in
WWW/EGCatLoader/Account.pm).

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm

index 7b0c1a1..489594c 100644 (file)
@@ -893,15 +893,22 @@ sub attempt_hold_placement {
 
                     if (ref $result eq 'HASH') {
                         $hdata->{hold_failed_event} = $result->{last_event};
+
+                        if ($result->{age_protected_copy}) {
+                            $hdata->{could_override} = 1;
+                            $hdata->{age_protect} = 1;
+                        } else {
+                            $hdata->{could_override} = $self->test_could_override($hdata->{hold_failed_event});
+                        }
                     } elsif (ref $result eq 'ARRAY') {
-                        $hdata->{hold_failed_event} = pop @$result;
-                    }
+                        $hdata->{hold_failed_event} = $result->[0];
 
-                    if($result->{age_protected_copy}) {
-                        $hdata->{could_override} = 1;
-                        $hdata->{age_protect} = 1;
-                    } else {
-                        $hdata->{could_override} = $self->test_could_override($hdata->{hold_failed_event});
+                        if ($result->[3]) { # age_protect_only
+                            $hdata->{could_override} = 1;
+                            $hdata->{age_protect} = 1;
+                        } else {
+                            $hdata->{could_override} = $self->test_could_override($hdata->{hold_failed_event});
+                        }
                     }
                 }
             }