From f1389c8c5cdff9e270450ef030cf2eeb75ffa6ca Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Tue, 5 Nov 2019 05:42:54 +0100 Subject: [PATCH] Fix bug: would eat its own queued entry, resulting in no-op It would work for the first item because the size >= 2 guard prevented the rest of the sub from running. --- plugins/repeat | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/repeat b/plugins/repeat index 5ff2383..e05b1d0 100644 --- a/plugins/repeat +++ b/plugins/repeat @@ -74,9 +74,13 @@ sub hook_added_entry { my @entries = $cart->entries; my @planned = $cart->entries('_repeat'); - return ABORT, "Multiple repeats queued; I'm confused." if @planned > 1; + return if not @planned; + return ABORT, "Multiple repeats queued; I'm confused." if @planned > 1; return ABORT, $err_pfand if $cart->entries('is_pfand'); + return if $planned[0] == $entries[-1]; + return ABORT, "Queued repeat is not the penultimate item; I'm confused" + if $entries[-2] != $planned[0]; my $num = $planned[0]->quantity;