From f2f02dfba6bbd0afd7ba8f72ac9b226e9f545586 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 15 Dec 2023 13:12:27 +0000 Subject: [PATCH] Bug 35570: Atomicupdate Move stuff out of 'FreeForm' into 'Standard' This atomicupdate will printout the changes it made, if any. It will also print out the report IDs of reports that may contain occurrences of 'FreeForm'. This is to give the sys admin the chance to fix those reports before users. To test, empty k-t-d: 1) Run updatedatabase, notice nothing happens 2) Install FreeForm, run: bash <(curl -s https://raw.githubusercontent.com/ammopt/koha-ill-dev/master/start-ill-dev.sh) 3) Create a new 'FreeForm' ILL batch (requires a metadata enrichment plugin like https://github.com/PTFS-Europe/koha-plugin-api-pubmed) 4) Add '123' to the pubmedid list of identifiers and finish creating the batch 5) Upon creating the batch, you will now have 1 request, 1 batch and a few illrequestattributes in the 'FreeForm' backend 6) Run the updatedatabase again, notice the print outs. 7) Create a saved sql report like: 'Select * from illrequests where backend="FreeForm";' 8) Run the updatedatabase again, notice you get a warning for the above report Signed-off-by: David Nind --- .../data/mysql/atomicupdate/bug_35570.pl | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_35570.pl diff --git a/installer/data/mysql/atomicupdate/bug_35570.pl b/installer/data/mysql/atomicupdate/bug_35570.pl new file mode 100644 index 0000000000..a052b64541 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35570.pl @@ -0,0 +1,70 @@ +use Modern::Perl; + +use C4::Context; +use Koha::Reports; +use Term::ANSIColor qw(:constants); + +return { + bug_number => "35570", + description => "Update 'FreeForm' ILL backend to 'Standard'", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + my ($illbatches) = $dbh->selectrow_array( + q| + SELECT count(*) from illbatches where backend = 'FreeForm'; + | + ); + + if ($illbatches) { + $dbh->do("UPDATE illbatches SET backend = 'Standard' where backend = 'FreeForm'"); + say $out GREEN, "Bug 35570: Updated ILL batches from 'FreeForm' to 'Standard"; + } + + my ($illrequestattributes) = $dbh->selectrow_array( + q| + SELECT count(*) from illrequestattributes where backend = 'FreeForm'; + | + ); + + if ($illrequestattributes) { + $dbh->do("UPDATE illrequestattributes SET backend = 'Standard' where backend = 'FreeForm'"); + say $out GREEN, "Bug 35570: Updated ILL request attributes from 'FreeForm' to 'Standard"; + } + + my ($illrequests) = $dbh->selectrow_array( + q| + SELECT count(*) from illrequests where backend = 'FreeForm'; + | + ); + + if ($illrequests) { + $dbh->do("UPDATE illrequests SET backend = 'Standard' where backend = 'FreeForm'"); + say $out GREEN, "Bug 35570: Updated ILL requests from 'FreeForm' to 'Standard"; + } + + my $reports = join( + "\n", + map( "\tReport ID: " + . $_->id + . ' | Edit link: ' + . C4::Context->preference('staffClientBaseURL') + . '/cgi-bin/koha/reports/guided_reports.pl?reports=' + . $_->id + . "&phase=Edit%20SQL", + Koha::Reports->search( { savedsql => { -like => "%FreeForm%" } } )->as_list ) + ); + + if ($reports) { + say $out YELLOW, + "Bug 35570: **ACTION REQUIRED**: Saved SQL reports containing occurrences of 'FreeForm' were found.\nThe following reports MUST be updated accordingly ('FreeForm' -> 'Standard'):"; + say $out BRIGHT_YELLOW, + $reports; + }else{ + say $out "Bug 35570: Finished database update."; + } + + + }, +}; -- 2.30.2