From f64d0d9038a58abe360744200348950688e834cd Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 6 Feb 2019 12:49:58 +0000 Subject: [PATCH] Bug 22278: Clear cache when creating new report groups or subgroups When a user adds a new group we create it, then fetch the groups from the cache. However, we aren't clearing the cache on creation. This patch fixes that To test: 0) Start a new report 1) Pick create for the group 2) Enter code and value 3) Save 4) You remain on the page and value and code are now empty (ok) 5) BUT: The pull down for the group remains "None" instead of reflecting the new group 6) Open a new tab and browse to reports - note the group exists and the report is in it 7) On original tab save report again, the group was not selected so is lost 8) Apply patch 9) Retest with a new report 10) Group is created, saved, and selected upon save 11) Subsequent edits include the new group 12) Test with subgroups as well Signed-off-by: Liz Rea Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens (cherry picked from commit ea36265697c85cfb1f7de0b2344ef8647dc31387) Signed-off-by: Martin Renvoize --- reports/guided_reports.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index 24dd1081dc..67a8eb993f 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -592,7 +592,6 @@ elsif ( $phase eq 'Save Report' ) { } create_non_existing_group_and_subgroup($input, $group, $subgroup); - ## FIXME this is AFTER entering a name to save the report under if ($sql =~ /;?\W?(UPDATE|DELETE|DROP|INSERT|SHOW|CREATE)\W/i) { push @errors, {sqlerr => $1}; @@ -1039,7 +1038,6 @@ sub groups_with_subgroups { sub create_non_existing_group_and_subgroup { my ($input, $group, $subgroup) = @_; - if (defined $group and $group ne '') { my $report_groups = C4::Reports::Guided::get_report_groups; if (not exists $report_groups->{$group}) { @@ -1049,6 +1047,9 @@ sub create_non_existing_group_and_subgroup { authorised_value => $group, lib => $groupdesc, })->store; + my $cache_key = "AuthorisedValues-REPORT_GROUP-0-".C4::Context->userenv->{"branch"}; + my $cache = Koha::Caches->get_instance(); + my $result = $cache->clear_from_cache($cache_key); } if (defined $subgroup and $subgroup ne '') { if (not exists $report_groups->{$group}->{subgroups}->{$subgroup}) { @@ -1059,6 +1060,9 @@ sub create_non_existing_group_and_subgroup { lib => $subgroupdesc, lib_opac => $group, })->store; + my $cache_key = "AuthorisedValues-REPORT_SUBGROUP-0-".C4::Context->userenv->{"branch"}; + my $cache = Koha::Caches->get_instance(); + my $result = $cache->clear_from_cache($cache_key); } } } -- 2.39.5