From 4b0ebac9980789ede9aa999bdc8bbc73d7057845 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 19 Mar 2013 01:49:01 -0700 Subject: [PATCH] Bug 8562 - RandomizeHoldsQueueWeight ignored if StaticHoldsQueueWeight is empty. If StaticHoldsQueueWeight is empty, but RandomizeHoldsQueueWeight is enabled, the script build_holds_queue.pl should select branches for fulfillment requests at random. Instead, it will select them in alphabetical order. Test Plan: 1) Apply patch 2) Set the system preference StaticHoldsQueueWeight to empty 3) Create a hold on an record with items at multiple libraries 4) Run build_holds_queue.pl 5) Look at the holds queue report from the circulation home page 6) Run build_holds_queue.pl again 7) Look at the holds queue report again, note the library chosen for fulfillment of the hold has likely changed. 8) Repeat steps 6-7 until you are satisfied the library to fulfill the hold is chosen at random. Signed-off-by: Leila and Frido --- C4/HoldsQueue.pm | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 7d38963..7377d51 100755 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -570,14 +570,15 @@ sub _trim { } sub load_branches_to_pull_from { - my $static_branch_list = C4::Context->preference("StaticHoldsQueueWeight") - or return; + my $static_branch_list = C4::Context->preference("StaticHoldsQueueWeight"); my @branches_to_use = map _trim($_), split /,/, $static_branch_list; @branches_to_use = shuffle(@branches_to_use) if C4::Context->preference("RandomizeHoldsQueueWeight"); - return \@branches_to_use; + @branches_to_use = shuffle keys %{GetBranches()} unless ( @branches_to_use ); + + return ( @branches_to_use ) ? \@branches_to_use : undef; } sub least_cost_branch { -- 1.7.2.5