Bugzilla – Attachment 100214 Details for
Bug 19475
Calendar copy creates duplicates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19475: Don't copy holiday if it already exists in target calendar
0001-Bug-19475-Don-t-copy-holiday-if-it-already-exists.patch (text/plain), 2.96 KB, created by
Emmi Takkinen
on 2020-03-06 08:23:35 UTC
(
hide
)
Description:
Bug 19475: Don't copy holiday if it already exists in target calendar
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2020-03-06 08:23:35 UTC
Size:
2.96 KB
patch
obsolete
>From 8f26ee99d2732045290583b6f95c6698f7b7ea6c Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@outlook.com> >Date: Wed, 4 Mar 2020 13:54:34 +0200 >Subject: [PATCH] Bug 19475: Don't copy holiday if it already exists in target > calendar > >Calendars copy tool created duplicate values to database. >Holidays in target calendar weren't checked before >inserting new holidays. This patch fixes this. > >To test: >1. Add holidays for branch A >2. Copy branch A calendar to branch B >3. Repeat copy to branch B >=> Check database, branch B has now duplicate holidays >4. Delete holidays from branches A and B >5. Apply patch >6. Repeat steps 1-3 >=> Check database, no duplicates > >Sponsored-by: Koha-Suomi Oy >--- > C4/Calendar.pm | 38 ++++++++++++++++++++++++++++++-------- > 1 file changed, 30 insertions(+), 8 deletions(-) > >diff --git a/C4/Calendar.pm b/C4/Calendar.pm >index 321aad76d5..1f35c15a94 100644 >--- a/C4/Calendar.pm >+++ b/C4/Calendar.pm >@@ -690,15 +690,37 @@ sub copy_to_branch { > my $today = sprintf ISO_DATE_FORMAT, $y,$m,$d; > > my $wdh = $self->get_week_days_holidays; >- $target_calendar->insert_week_day_holiday( weekday => $_, %{ $wdh->{$_} } ) >- foreach keys %$wdh; >- $target_calendar->insert_day_month_holiday(%$_) >- foreach values %{ $self->get_day_month_holidays }; >- $target_calendar->insert_exception_holiday(%$_) >- foreach grep { $_->{date} gt $today } values %{ $self->get_exception_holidays }; >- $target_calendar->insert_single_holiday(%$_) >- foreach grep { $_->{date} gt $today } values %{ $self->get_single_holidays }; >+ my $target_wdh = $target_calendar->get_week_days_holidays; >+ foreach my $key (keys %$wdh) { >+ unless (grep { $_ eq $key } keys %$target_wdh) { >+ $target_calendar->insert_week_day_holiday( weekday => $key, %{ $wdh->{$key} } ) >+ } >+ } >+ >+ my $dmh = $self->get_day_month_holidays; >+ my $target_dmh = $target_calendar->get_day_month_holidays; >+ foreach my $values (values %$dmh) { >+ unless (grep { $_->{day} eq $values->{day} && $_->{month} eq $values->{month} } values %$target_dmh) { >+ $target_calendar->insert_day_month_holiday(%{ $values }); >+ } >+ } > >+ my $exception_holidays = $self->get_exception_holidays; >+ my $target_exceptions = $target_calendar->get_exception_holidays; >+ foreach my $values ( grep {$_->{date} gt $today} values %{ $exception_holidays }) { >+ unless ( grep { $_->{date} eq $values->{date} } values %$target_exceptions) { >+ $target_calendar->insert_exception_holiday(%{ $values }); >+ } >+ } >+ >+ my $single_holidays = $self->get_single_holidays; >+ my $target_singles = $target_calendar->get_single_holidays; >+ foreach my $values ( grep {$_->{date} gt $today} values %{ $single_holidays }) { >+ unless ( grep { $_->{date} eq $values->{date} } values %$target_singles){ >+ $target_calendar->insert_single_holiday(%{ $values }); >+ } >+ } >+ > return 1; > } > >-- >2.17.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19475
:
100214
|
100483
|
100668
|
101846
|
101847
|
102072
|
102073
|
102074