From 575e90f88f42f2ca6d8ca89f30c1c085fd7e9cfd Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 1 Jul 2026 18:45:53 +0100 Subject: [PATCH] Bug 41029: (QA follow-up) Seed add_to_basket record source and tidy atomicupdate Without a matching entry in the record_sources table, the new "Add to basket" option never appears in the Source filter dropdown of the marc-overlay-rules admin page for module=source, since that dropdown is populated from Koha::RecordSources, not the template's label switch. Seed it in both the mandatory install-time data and the upgrade atomicupdate, matching how batchimport/z3950/etc. were introduced. Also drop the unused say_warning import, route success messages through say_success instead of a bare say, and simplify the selectrow_array calls. Signed-off-by: Martin Renvoize Signed-off-by: Pedro Amorim --- .../data/mysql/atomicupdate/bug_41029.pl | 26 ++++++++++--------- .../data/mysql/mandatory/record_sources.sql | 1 + 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_41029.pl b/installer/data/mysql/atomicupdate/bug_41029.pl index b252c6d1df..993f5d38f8 100755 --- a/installer/data/mysql/atomicupdate/bug_41029.pl +++ b/installer/data/mysql/atomicupdate/bug_41029.pl @@ -1,5 +1,5 @@ use Modern::Perl; -use Koha::Installer::Output qw(say_warning say_success say_info); +use Koha::Installer::Output qw(say_success say_info); return { bug_number => "41029", @@ -8,16 +8,18 @@ return { my ($args) = @_; my ( $dbh, $out ) = @$args{qw(dbh out)}; - my $existing_batchimport_rules_count = ( - $dbh->selectrow_array( - 'SELECT COUNT(*) FROM marc_overlay_rules WHERE module="source" and filter="batchimport"', undef - ) - )[0]; - my $existing_add_to_basket_rules_count = ( - $dbh->selectrow_array( - 'SELECT COUNT(*) FROM marc_overlay_rules WHERE module="source" and filter="add_to_basket"', undef - ) - )[0]; + $dbh->do( + q{ + INSERT IGNORE INTO record_sources (`name`, `can_be_edited`, `is_system`) + VALUES ('add_to_basket', 1, 1) + } + ); + say_success( $out, "Added 'add_to_basket' record source" ); + + my $existing_batchimport_rules_count = scalar $dbh->selectrow_array( + 'SELECT COUNT(*) FROM marc_overlay_rules WHERE module="source" AND filter="batchimport"'); + my $existing_add_to_basket_rules_count = scalar $dbh->selectrow_array( + 'SELECT COUNT(*) FROM marc_overlay_rules WHERE module="source" AND filter="add_to_basket"'); if ( $existing_batchimport_rules_count > 0 && $existing_add_to_basket_rules_count == 0 ) { say_info( $out, "Existing batchimport marc_overlay_rules found and no add_to_basket rules found" ); $dbh->do( @@ -28,7 +30,7 @@ return { WHERE module = 'source' AND filter = 'batchimport' } ); - say $out "Added existing batchimport overlay rules as add_to_basket rules"; + say_success( $out, "Added existing batchimport overlay rules as add_to_basket rules" ); } else { say_info( $out, diff --git a/installer/data/mysql/mandatory/record_sources.sql b/installer/data/mysql/mandatory/record_sources.sql index e7a25409c8..5136ba7fdc 100644 --- a/installer/data/mysql/mandatory/record_sources.sql +++ b/installer/data/mysql/mandatory/record_sources.sql @@ -2,6 +2,7 @@ INSERT IGNORE INTO record_sources ( name, can_be_edited, is_system ) VALUES ('batchmod', 1, 1 ), ('intranet', 1, 1 ), ('batchimport', 1, 1 ), +('add_to_basket', 1, 1 ), ('z3950', 1, 1 ), ('bulkmarcimport', 1, 1 ), ('import_lexile', 1, 1 ); \ No newline at end of file