From df92c9ddf9316119e513dc93c8ece32ccab9a511 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Thu, 13 May 2021 10:31:08 +0100 Subject: [PATCH] Bug 28340: Alphabetise metadata for notices This commit sorts metadata by key prior to preparing a notice with it Test plan: - Do not apply patch - Create a report with the following SQL: SELECT * FROM message_queue; - Create an ILL request with plenty of metadata - Go to "Manage request" - Send a notice to a patron - Run the report created earlier => TEST: - Observe that the metadata is in random order - Apply the patch - Create an ILL request with plenty of metadata - Go to "Manage request" - Send a notice to a patron - Run the report created earlier => TEST: - Observe that the metadata is now sorted alphabetically by key Signed-off-by: Jill Tivey Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- Koha/Illrequest.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 7decbc1f2d..7ea301fde3 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -1556,7 +1556,8 @@ sub get_notice { ); my $metahash = $self->metadata; my @metaarray = (); - while (my($key, $value) = each %{$metahash}) { + foreach my $key (sort { lc $a cmp lc $b } keys %{$metahash}) { + my $value = $metahash->{$key}; push @metaarray, "- $key: $value" if $value; } my $metastring = join("\n", @metaarray); -- 2.39.5