From: Mike Rylander <mrylander@gmail.com>
Date: Tue, 3 Sep 2019 20:02:53 +0000 (-0400)
Subject: LP1832897: Belt-and-suspenders for making sure max_items is set
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=94fb41cbdd52f09de09d91db10fcea0b520fed25;p=evergreen%2Fjoelewis.git

LP1832897: Belt-and-suspenders for making sure max_items is set

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
---

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Carousel.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Carousel.pm
index 0b64841d4d..9e9fa616fc 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Carousel.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Carousel.pm
@@ -176,12 +176,16 @@ sub add_carousel_from_bucket {
 
     $e->xact_begin;
 
+    # gather old entries to get a count and set max_items appropriately
+    my $entries = $e->search_container_biblio_record_entry_bucket_item({ bucket => $bucket_id });
+
     my $carousel = Fieldmapper::container::carousel->new;
     $carousel->name($carousel_name);
     $carousel->type(1); # manual
     $carousel->owner($e->requestor->ws_ou);
     $carousel->creator($e->requestor->id);
     $carousel->editor($e->requestor->id);
+    $carousel->max_items(scalar(@$entries));
     $e->create_container_carousel($carousel) or return $e->event;
 
     # and the bucket
@@ -199,7 +203,6 @@ sub add_carousel_from_bucket {
     $e->update_container_carousel($carousel) or return $e->event;
 
     # and fill it
-    my $entries = $e->search_container_biblio_record_entry_bucket_item({ bucket => $bucket_id });
     foreach my $entry (@$entries) {
         $entry->clear_id;
         $entry->bucket($bucket->id);