Bug 33268: If rules exists add rules to preserve current behavior

Signed-off-by: Jan Kissig <bibliothek@th-wildau.de>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
David Gustafsson 2024-03-05 16:47:29 +01:00 committed by Katrin Fischer
parent cb2d98fc5b
commit e2c0403440
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 32 additions and 0 deletions

View File

@ -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";
},
};