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 <Jill.Tivey@sasa.gov.scot>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Andrew Isherwood 2021-05-13 10:31:08 +01:00 committed by Jonathan Druart
parent 09b66a8035
commit df92c9ddf9
1 changed files with 2 additions and 1 deletions

View File

@ -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);