From 7967dab02862cf90f6e5f61dcdcef1532fd5dfa1 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 9 Feb 2023 15:29:39 +0000 Subject: [PATCH] Bug 32334: (QA follow-up) Force mutual exclusiveness of cmdline flags Test plan: Run sync_db_comments.pl --clear --renumber Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- misc/maintenance/sync_db_comments.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/misc/maintenance/sync_db_comments.pl b/misc/maintenance/sync_db_comments.pl index 6fbd2e6d52..ffeb930e96 100755 --- a/misc/maintenance/sync_db_comments.pl +++ b/misc/maintenance/sync_db_comments.pl @@ -42,10 +42,12 @@ GetOptions( my $commenter = Koha::Database::Commenter->new({ database => delete $cmd_args->{database}, dbh => C4::Context->dbh }); if( $cmd_args->{help} ) { pod2usage( -verbose => 2 ); -} elsif( delete $cmd_args->{clear} ) { # clear overrules reset +} elsif( ($cmd_args->{clear}||0) + ($cmd_args->{renumber}||0) + ($cmd_args->{reset}||0) > 1 ) { + print "You cannot pass the clear, renumber and reset flags together\n"; +} elsif( delete $cmd_args->{clear} ) { alert_dry_run( $cmd_args->{dry_run} ); $commenter->clear( $cmd_args ); -} elsif( delete $cmd_args->{reset} ) { # reset overrules renumber +} elsif( delete $cmd_args->{reset} ) { alert_dry_run( $cmd_args->{dry_run} ); $commenter->reset_to_schema( $cmd_args ); } elsif( delete $cmd_args->{renumber} ) { @@ -106,8 +108,7 @@ misc/maintenance/sync_db_comments.pl The script is just a wrapper around the module Koha::Database::Commenter. A test script is provided in t/db_dependent/Koha/Database/Commenter.t. - The flags -clear, -reset and -renumber are mutually exclusive. Clear ignores - the other two, reset ignores renumber. + The flags -clear, -reset and -renumber are mutually exclusive. The renumber option has been helpful in verifying that the alter table operations work on the complete Koha database. It is not recommended to run -- 2.39.5