From 928a76a516e26bf79f1b8d7a1f7e6338140f2721 Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Tue, 5 Mar 2024 16:47:29 +0100 Subject: [PATCH] Bug 33268: If rules exists add rules to preserve current behavior --- ...preserve_current_overlay_rules_behavior.pl | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_33268-add_rules_to_preserve_current_overlay_rules_behavior.pl diff --git a/installer/data/mysql/atomicupdate/bug_33268-add_rules_to_preserve_current_overlay_rules_behavior.pl b/installer/data/mysql/atomicupdate/bug_33268-add_rules_to_preserve_current_overlay_rules_behavior.pl new file mode 100755 index 0000000000..88d4a9e334 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_33268-add_rules_to_preserve_current_overlay_rules_behavior.pl @@ -0,0 +1,32 @@ +use Modern::Perl; + +return { + bug_number => "33268", + description => "Add rules to preserve current marc record overlay rules behavior", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Insert filter wildcard rules equivalent to the default + # fallback rule (overwrite) if wildcard rules exists for a module + # and other tag wildcard rule not already defined for said module + + my $query = q{ + SELECT DISTINCT `module`, `filter` FROM `marc_overlay_rules` + WHERE + `filter` <> "*" AND + `module` IN (SELECT `module` FROM `marc_overlay_rules` WHERE `filter` = "*") AND + `filter` NOT IN (SELECT `filter` FROM `marc_overlay_rules` WHERE `tag` = "*") + }; + my @results = $dbh->selectall_array( $query ); + for my $result ( @results ) { + my ($module, $filter) = @{$result}; + $query = q{ + INSERT INTO `marc_overlay_rules`(`tag`, `module`, `filter`, `add`, `append`, `remove`, `delete`) + VALUES(?, ?, ?, ?, ?, ?, ?) + }; + $dbh->do($query, undef, '*', $module, $filter, 1, 1, 1, 1); + } + say $out "Added record overlay rules to preserve current behavior"; + }, +}; -- 2.44.0