View | Details | Raw Unified | Return to bug 33268
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_33268-add_rules_to_preserve_current_overlay_rules_behavior.pl (-1 / +32 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "33268",
5
    description => "Add rules to preserve current marc record overlay rules behavior",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        # Insert filter wildcard rules equivalent to the default
11
        # fallback rule (overwrite) if wildcard rules exists for a module
12
        # and other tag wildcard rule not already defined for said module
13
14
        my $query = q{
15
            SELECT DISTINCT `module`, `filter` FROM `marc_overlay_rules`
16
            WHERE
17
                `filter` <> "*" AND
18
                `module` IN (SELECT `module` FROM `marc_overlay_rules` WHERE `filter` = "*") AND
19
                `filter` NOT IN (SELECT `filter` FROM `marc_overlay_rules` WHERE `tag` = "*")
20
        };
21
        my @results = $dbh->selectall_array( $query );
22
        for my $result ( @results ) {
23
            my ($module, $filter) = @{$result};
24
            $query = q{
25
                INSERT INTO `marc_overlay_rules`(`tag`, `module`, `filter`, `add`, `append`, `remove`, `delete`)
26
                VALUES(?, ?, ?, ?, ?, ?, ?)
27
            };
28
            $dbh->do($query, undef, '*', $module, $filter, 1, 1, 1, 1);
29
        }
30
        say $out "Added record overlay rules to preserve current behavior";
31
    },
32
};

Return to bug 33268