From 6b61423e2f03ada4f727538ae7cfe75de003ebf0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 2 Feb 2026 10:11:04 +0100 Subject: [PATCH] Bug 41746: Bug Deal with end of files (, vs ;) --- Koha/Devel/Sysprefs.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Koha/Devel/Sysprefs.pm b/Koha/Devel/Sysprefs.pm index fd0ce134284..09e9e13231a 100644 --- a/Koha/Devel/Sysprefs.pm +++ b/Koha/Devel/Sysprefs.pm @@ -137,6 +137,7 @@ sub add_new_pref { my @sysprefs; for my $line (@lines) { chomp $line; + next if $line eq ';'; # Removing and adding it later # FIXME Explode if already exists? my $syspref = $self->extract_syspref_from_line($line); @@ -153,6 +154,7 @@ sub add_new_pref { $new_syspref->{type} ) }; + @sysprefs = sort { defined $a->{variable} && defined $b->{variable} @@ -160,8 +162,16 @@ sub add_new_pref { cmp( lc( $b->{variable} ) =~ s/_/ZZZ/gr ) # mysql sorts underscore last, if you modify this qa-test-tools will need adjustments + || defined $a->{variable} } @sysprefs; - write_file( $self->{filepath}, join( "\n", map { $_->{line} } @sysprefs ) ); + + $sysprefs[-1]->{line} =~ s/,$//; + if ( $sysprefs[-2]->{line} =~ /[^,]$/ ) { + $sysprefs[-2]->{line} .= ','; + } + push @sysprefs, { line => ';' }; + + write_file( $self->{filepath}, join( "\n", map { $_->{line} } @sysprefs ) . "\n" ); } 1; -- 2.43.0