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

(-)a/C4/Calendar.pm (-7 / +7 lines)
Lines 278-284 sub insert_single_holiday { Link Here
278
    # changed the 'single_holidays' table, lets force/reset its cache
278
    # changed the 'single_holidays' table, lets force/reset its cache
279
    my $cache = Koha::Caches->get_instance();
279
    my $cache = Koha::Caches->get_instance();
280
    $cache->clear_from_cache( 'single_holidays') ;
280
    $cache->clear_from_cache( 'single_holidays') ;
281
    $cache->clear_from_cache( 'exception_holidays') ;
281
    $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ;
282
282
283
    return $self;
283
    return $self;
284
284
Lines 323-329 sub insert_exception_holiday { Link Here
323
    # changed the 'single_holidays' table, lets force/reset its cache
323
    # changed the 'single_holidays' table, lets force/reset its cache
324
    my $cache = Koha::Caches->get_instance();
324
    my $cache = Koha::Caches->get_instance();
325
    $cache->clear_from_cache( 'single_holidays') ;
325
    $cache->clear_from_cache( 'single_holidays') ;
326
    $cache->clear_from_cache( 'exception_holidays') ;
326
    $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ;
327
327
328
    return $self;
328
    return $self;
329
}
329
}
Lines 424-430 UPDATE special_holidays SET title = ?, description = ? Link Here
424
    # changed the 'single_holidays' table, lets force/reset its cache
424
    # changed the 'single_holidays' table, lets force/reset its cache
425
    my $cache = Koha::Caches->get_instance();
425
    my $cache = Koha::Caches->get_instance();
426
    $cache->clear_from_cache( 'single_holidays') ;
426
    $cache->clear_from_cache( 'single_holidays') ;
427
    $cache->clear_from_cache( 'exception_holidays') ;
427
    $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ;
428
428
429
    return $self;
429
    return $self;
430
}
430
}
Lines 467-473 UPDATE special_holidays SET title = ?, description = ? Link Here
467
    # changed the 'single_holidays' table, lets force/reset its cache
467
    # changed the 'single_holidays' table, lets force/reset its cache
468
    my $cache = Koha::Caches->get_instance();
468
    my $cache = Koha::Caches->get_instance();
469
    $cache->clear_from_cache( 'single_holidays') ;
469
    $cache->clear_from_cache( 'single_holidays') ;
470
    $cache->clear_from_cache( 'exception_holidays') ;
470
    $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ;
471
471
472
    return $self;
472
    return $self;
473
}
473
}
Lines 548-554 sub delete_holiday { Link Here
548
    # changed the 'single_holidays' table, lets force/reset its cache
548
    # changed the 'single_holidays' table, lets force/reset its cache
549
    my $cache = Koha::Caches->get_instance();
549
    my $cache = Koha::Caches->get_instance();
550
    $cache->clear_from_cache( 'single_holidays') ;
550
    $cache->clear_from_cache( 'single_holidays') ;
551
    $cache->clear_from_cache( 'exception_holidays') ;
551
    $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ;
552
552
553
    return $self;
553
    return $self;
554
}
554
}
Lines 579-585 sub delete_holiday_range { Link Here
579
    # changed the 'single_holidays' table, lets force/reset its cache
579
    # changed the 'single_holidays' table, lets force/reset its cache
580
    my $cache = Koha::Caches->get_instance();
580
    my $cache = Koha::Caches->get_instance();
581
    $cache->clear_from_cache( 'single_holidays') ;
581
    $cache->clear_from_cache( 'single_holidays') ;
582
    $cache->clear_from_cache( 'exception_holidays') ;
582
    $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ;
583
583
584
}
584
}
585
585
Lines 633-639 sub delete_exception_holiday_range { Link Here
633
    # changed the 'single_holidays' table, lets force/reset its cache
633
    # changed the 'single_holidays' table, lets force/reset its cache
634
    my $cache = Koha::Caches->get_instance();
634
    my $cache = Koha::Caches->get_instance();
635
    $cache->clear_from_cache( 'single_holidays') ;
635
    $cache->clear_from_cache( 'single_holidays') ;
636
    $cache->clear_from_cache( 'exception_holidays') ;
636
    $cache->clear_from_cache( 'exception_holidays_'.$self->{branchcode}) ;
637
}
637
}
638
638
639
=head2 isHoliday
639
=head2 isHoliday
(-)a/Koha/Calendar.pm (-3 / +4 lines)
Lines 54-65 sub _init { Link Here
54
sub exception_holidays {
54
sub exception_holidays {
55
    my ( $self ) = @_;
55
    my ( $self ) = @_;
56
56
57
    my $branch = $self->{branchcode};
57
    my $cache  = Koha::Caches->get_instance();
58
    my $cache  = Koha::Caches->get_instance();
58
    my $cached = $cache->get_from_cache('exception_holidays');
59
    my $key = 'exception_holidays_'.$branch;
60
    my $cached = $cache->get_from_cache($key);
59
    return $cached if $cached;
61
    return $cached if $cached;
60
62
61
    my $dbh = C4::Context->dbh;
63
    my $dbh = C4::Context->dbh;
62
    my $branch = $self->{branchcode};
63
    my $exception_holidays_sth = $dbh->prepare(
64
    my $exception_holidays_sth = $dbh->prepare(
64
'SELECT day, month, year FROM special_holidays WHERE branchcode = ? AND isexception = 1'
65
'SELECT day, month, year FROM special_holidays WHERE branchcode = ? AND isexception = 1'
65
    );
66
    );
Lines 76-82 sub exception_holidays { Link Here
76
    }
77
    }
77
    $self->{exception_holidays} =
78
    $self->{exception_holidays} =
78
      DateTime::Set->from_datetimes( dates => $dates );
79
      DateTime::Set->from_datetimes( dates => $dates );
79
    $cache->set_in_cache( 'exception_holidays', $self->{exception_holidays} );
80
    $cache->set_in_cache( $key, $self->{exception_holidays} );
80
    return $self->{exception_holidays};
81
    return $self->{exception_holidays};
81
}
82
}
82
83
(-)a/t/Calendar.t (-2 lines)
Lines 78-84 fixtures_ok [ Link Here
78
78
79
my $cache = Koha::Caches->get_instance();
79
my $cache = Koha::Caches->get_instance();
80
$cache->clear_from_cache( 'single_holidays' ) ;
80
$cache->clear_from_cache( 'single_holidays' ) ;
81
$cache->clear_from_cache( 'exception_holidays' ) ;
82
81
83
# 'MPL' branch is arbitrary, is not used at all but is needed for initialization
82
# 'MPL' branch is arbitrary, is not used at all but is needed for initialization
84
my $cal = Koha::Calendar->new( branchcode => 'MPL' );
83
my $cal = Koha::Calendar->new( branchcode => 'MPL' );
Lines 311-315 subtest 'days_mode parameter' => sub { Link Here
311
310
312
END {
311
END {
313
    $cache->clear_from_cache( 'single_holidays' ) ;
312
    $cache->clear_from_cache( 'single_holidays' ) ;
314
    $cache->clear_from_cache( 'exception_holidays' ) ;
315
};
313
};
(-)a/t/db_dependent/Holidays.t (-2 / +1 lines)
Lines 82-88 subtest 'exception_holidays() tests' => sub { Link Here
82
    use POSIX qw(tzset);
82
    use POSIX qw(tzset);
83
    tzset;
83
    tzset;
84
84
85
    my $calendar = Koha::Calendar->new( branchcode => $branch );
85
    $calendar = Koha::Calendar->new( branchcode => $branch );
86
86
87
    C4::Calendar->new( branchcode => $branch )->insert_exception_holiday(
87
    C4::Calendar->new( branchcode => $branch )->insert_exception_holiday(
88
        day         => 6,
88
        day         => 6,
89
- 

Return to bug 26000