From 198252a292572d99351b50053a84b32369b37bc8 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 22 Jul 2024 10:36:40 +0100 Subject: [PATCH] Bug 29509: DBRev 24.06.00.018 Signed-off-by: Martin Renvoize --- Koha.pm | 2 +- .../bug_29509.pl => db_revs/240600018.pl} | 43 ++++++++++++++----- 2 files changed, 33 insertions(+), 12 deletions(-) rename installer/data/mysql/{atomicupdate/bug_29509.pl => db_revs/240600018.pl} (80%) diff --git a/Koha.pm b/Koha.pm index 028d303cf0..56b4e968bc 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "24.06.00.017"; +$VERSION = "24.06.00.018"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_29509.pl b/installer/data/mysql/db_revs/240600018.pl similarity index 80% rename from installer/data/mysql/atomicupdate/bug_29509.pl rename to installer/data/mysql/db_revs/240600018.pl index b70fd3ce6b..891a6cd383 100755 --- a/installer/data/mysql/atomicupdate/bug_29509.pl +++ b/installer/data/mysql/db_revs/240600018.pl @@ -1,5 +1,6 @@ use Modern::Perl; -use Array::Utils qw( array_minus ); +use Koha::Installer::Output qw(say_warning say_failure say_success say_info); +use Array::Utils qw( array_minus ); return { bug_number => "29509", @@ -23,10 +24,15 @@ return { my @edit_borrowers = map { $_->[0] } @{ $sth2->fetchall_arrayref }; my @reduced = array_minus( @edit_borrowers, @exclusions ); my @rows_to_insert = ( map { [ $_, 4, "list_borrowers" ] } array_minus( @edit_borrowers, @exclusions ) ); - foreach my $row (@rows_to_insert) { $insert_sth->execute( @{$row} ); } - say $out "list_borrowers added to all users with edit_borrowers"; + my $count = 0; + foreach my $row (@rows_to_insert) { $insert_sth->execute( @{$row} ); $count++; } + + if ($count) { + say_info( $out, "list_borrowers added to $count users with edit_borrowers" ); + } # Check for 'circulate' or 'circulate > manage_bookings' permission + $count = 0; my $sth3 = $dbh->prepare("SELECT borrowernumber FROM user_permissions WHERE code = 'manage_bookings'"); $sth3->execute(); my @manage_bookings = map { $_->[0] } @{ $sth3->fetchall_arrayref }; @@ -35,10 +41,14 @@ return { my @circulate = map { $_->[0] } @{ $sth3_1->fetchall_arrayref }; my @bookings = ( @manage_bookings, @circulate ); @rows_to_insert = ( map { [ $_, 4, "list_borrowers" ] } array_minus( @bookings, @exclusions ) ); - foreach my $row (@rows_to_insert) { $insert_sth->execute( @{$row} ); } - say $out "list_borrowers added to all users with manage_bookings"; + foreach my $row (@rows_to_insert) { $insert_sth->execute( @{$row} ); $count++; } + + if ($count) { + say_info( $out, "list_borrowers added to $count users with manage_bookings" ); + } # Check for 'tools' or 'tools > label_creator' permission + $count = 0; my $sth4 = $dbh->prepare("SELECT borrowernumber FROM user_permissions WHERE code = 'label_creator'"); $sth4->execute(); my @label_creator = map { $_->[0] } @{ $sth4->fetchall_arrayref }; @@ -47,10 +57,14 @@ return { my @tools = map { $_->[0] } @{ $sth4_1->fetchall_arrayref }; my @labels = ( @label_creator, @tools ); @rows_to_insert = ( map { [ $_, 4, "list_borrowers" ] } array_minus( @labels, @exclusions ) ); - foreach my $row (@rows_to_insert) { $insert_sth->execute( @{$row} ); } - say $out "list_borrowers added to all users with label_creator"; + foreach my $row (@rows_to_insert) { $insert_sth->execute( @{$row} ); $count++; } + + if ($count) { + say_info( $out, "list_borrowers added to $count users with label_creator" ); + } # Check for 'serials' or 'serials > routing' permission + $count = 0; my $sth5 = $dbh->prepare("SELECT borrowernumber FROM user_permissions WHERE code = 'routing'"); $sth5->execute(); my @routing = map { $_->[0] } @{ $sth5->fetchall_arrayref }; @@ -59,10 +73,14 @@ return { my @serials = map { $_->[0] } @{ $sth5_1->fetchall_arrayref }; my @routing_lists = ( @routing, @serials ); @rows_to_insert = ( map { [ $_, 4, "list_borrowers" ] } array_minus( @routing_lists, @exclusions ) ); - foreach my $row (@rows_to_insert) { $insert_sth->execute( @{$row} ); } - say $out "list_borrowers added to all users with routing"; + foreach my $row (@rows_to_insert) { $insert_sth->execute( @{$row} ); $count++ } + + if ($count) { + say_info( $out, "list_borrowers added to $count users with routing" ); + } # Check for 'acquisitions' or 'acquisitions > order_manage' permission + $count = 0; my $sth6 = $dbh->prepare("SELECT borrowernumber FROM user_permissions WHERE code = 'order_manage'"); $sth6->execute(); my @order_manage = map { $_->[0] } @{ $sth6->fetchall_arrayref }; @@ -71,7 +89,10 @@ return { my @acquisitions = map { $_->[0] } @{ $sth6_1->fetchall_arrayref }; my @orders = ( @order_manage, @acquisitions ); @rows_to_insert = ( map { [ $_, 4, "list_borrowers" ] } array_minus( @orders, @exclusions ) ); - foreach my $row (@rows_to_insert) { $insert_sth->execute( @{$row} ); } - say $out "list_borrowers added to all users with order_manage"; + foreach my $row (@rows_to_insert) { $insert_sth->execute( @{$row} ); $count++ } + + if ($count) { + say_info( $out, "list_borrowers added to $count users with order_manage" ); + } }, }; -- 2.39.5