From 6cde7af8af76677d3a5a9ee4335fccf7499e24e4 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Sat, 23 Mar 2024 16:26:44 +0000 Subject: [PATCH] Bug 34611: (follow-up) Preserve statistic date if passed or null if not When testing the confirm option, I found that I was not warned on repeated runs. It turns out creating a new statistic object was setting the datetime to current timestamp This patch reset the object from the values passed To test: 1 - Disable Pseudonymization 2 - Perform some transactions, update datetimein DB to set them to yesterday 3 - Enable pseudonymization, ensure 'Date and time of transaction' is checked 4 - perl misc/maintenance/pseudonymize_statistics.pl -v 5 - Check the DB, note the new pseudonymized transactions have todays date 6 - DELETE FROM pseudonymized_transactions 7 - Apply patch 8 - perl misc/maintenance/pseudonymize_statistics.pl -v 9 - Check DB and confirm the transactoins have the original date 10 - DELETE FROM pseudonymized_transactions 11 - Unset date and time from pseudonymization pref 12 - perl misc/maintenance/pseudonymize_statistics.pl -v 13 - Confirm the transactions have a null date --- Koha/BackgroundJob/PseudonymizeStatistic.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Koha/BackgroundJob/PseudonymizeStatistic.pm b/Koha/BackgroundJob/PseudonymizeStatistic.pm index a1dd525b941..1d2bcd311cb 100644 --- a/Koha/BackgroundJob/PseudonymizeStatistic.pm +++ b/Koha/BackgroundJob/PseudonymizeStatistic.pm @@ -52,7 +52,12 @@ sub process { $self->start; my $statistic = $args->{statistic}; my $stat_object = Koha::Statistic->new($statistic); - Koha::PseudonymizedTransaction->new_from_statistic($stat_object)->store(); + # creating new object updates the timestamp to the current time + # we need to preserve the original transaction time + # if it was passed + $stat_object->datetime( $statistic->{datetime} ); + my $ps= Koha::PseudonymizedTransaction->new_from_statistic($stat_object); + $ps->store(); $self->finish( { data => "" } ); # We want to clear the job data to avoid storing patron information } -- 2.30.2