From 1158287a12b1acd9ccb1c63a1229b01d4f112cc8 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 | 71 +++++++++++++++++++ 1 file changed, 71 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 00000000000..07101efa0e6 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35570.pl @@ -0,0 +1,71 @@ +use Modern::Perl; + +use C4::Context; +use Koha::Reports; +use Term::ANSIColor; + +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 colored( "Bug 35570: Updated ILL batches from 'FreeForm' to 'Standard'", 'green' ); + } + + 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 colored( "Bug 35570: Updated ILL request attributes from 'FreeForm' to 'Standard'", 'green' ); + } + + 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 colored( "Bug 35570: Updated ILL requests from 'FreeForm' to 'Standard'", 'green' ); + } + + 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 colored( + "Bug 35570: **ACTION REQUIRED**: Saved SQL reports containing occurrences of 'FreeForm' were found. The following reports MUST be updated accordingly ('FreeForm' -> 'Standard'):", + 'yellow' + ); + say $out colored( $reports, 'blue'); + } else { + say $out "Bug 35570: Finished database update."; + } + + + }, +}; -- 2.30.2