From eeb026f7de3379c06af36e79e8e24f3f2f04742d Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Thu, 24 Sep 2020 13:55:55 +0100 Subject: [PATCH] Bug 23916: (follow-up) Don't anonymise issuer and don't update action_logs on upgrade This commit implements the two suggestions made by Nick in comment #41: - Removes the attempted retrospective addition of issuers to old issues. It was not particularly reliable, it also is not appropriate if the user does not wish to make use of this functionality - Removes the conversion of a NULL issuer to the anonymous borrowernumber when anonymising checkouts --- Koha/Patrons.pm | 3 +- .../atomicupdate/bug_23916_add_issues_issuer.perl | 32 ---------------------- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm index b826c44101..a958200d1b 100644 --- a/Koha/Patrons.pm +++ b/Koha/Patrons.pm @@ -196,8 +196,7 @@ sub anonymise_issue_history { ); my $anonymous_patron = C4::Context->preference('AnonymousPatron') || undef; $nb_rows += $old_issues_to_anonymise->update( { - 'old_issues.borrowernumber' => $anonymous_patron, - 'old_issues.issuer' => $anonymous_patron + 'old_issues.borrowernumber' => $anonymous_patron } ); } return $nb_rows; diff --git a/installer/data/mysql/atomicupdate/bug_23916_add_issues_issuer.perl b/installer/data/mysql/atomicupdate/bug_23916_add_issues_issuer.perl index 68df8a0447..589d3a91a8 100644 --- a/installer/data/mysql/atomicupdate/bug_23916_add_issues_issuer.perl +++ b/installer/data/mysql/atomicupdate/bug_23916_add_issues_issuer.perl @@ -13,38 +13,6 @@ if( CheckVersion( $DBversion ) ) { $dbh->do( q| ALTER TABLE old_issues ADD CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE | ); } - # Now attempt to migrate previously action logged issues into issues.issuer - # We assume that an item issued to a borrower on the same day is the same issue - # - # Get existing action logs - # - user = issuer - # - object = borrowernumber - # - info = itemnumber - my $action_logs = $dbh->selectall_arrayref("SELECT DATE(timestamp) AS dt, user, object, info FROM action_logs WHERE module='CIRCULATION' and action='ISSUE'", { Slice => {} }); - - foreach my $log( @{$action_logs} ) { - # Look for an issue of this item, to this borrower, on this day - # We're doing DATE comparison in the database to avoid invoking - # DateTime and it's performance sapping ways... - # - # If we're dealing with an actual borrower - if ($log->{user} != 0) { - my $done_issue = $dbh->do( - "UPDATE issues SET issuer = ? WHERE DATE(timestamp) = ? AND borrowernumber = ? AND itemnumber = ?", - undef, - ( $log->{user}, $log->{dt}, $log->{object}, $log->{info} ) - ); - # If we didn't find the issue in 'issues', look in 'old_issues' - if (!$done_issue) { - $dbh->do( - "UPDATE old_issues SET issuer = ? WHERE DATE(timestamp) = ? AND borrowernumber = ? AND itemnumber = ?", - undef, - ( $log->{user}, $log->{dt}, $log->{object}, $log->{info} ) - ); - } - } - } - SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug 23916 - Add issues.issuer)\n"; } -- 2.11.0