Bug 37182: Make Koha::Statistic->new preserve 'datetime' if passed

This patch does what the title says. This behavior is tested on the
previous patch. Tests are also added for the background job (which
relies on Koha::Statistic->new and was the evidence of this
overwrite behavior).

To test:

1. Apply the regression tests patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Statistic.t \
           t/db_dependent/Koha/BackgroundJob/PseudonymizeStatistic.t
=> FAIL: Tests don't pass :-/
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Tomás Cohen Arazi 2024-06-25 15:01:29 -03:00 committed by Katrin Fischer
parent 386cedeb73
commit 65375bc34d
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -90,7 +90,7 @@ sub new {
my @missing = map { exists $params->{$_} ? () : $_ } @mandatory_keys;
Koha::Exceptions::MissingParameter->throw( parameter => join( ',', @missing ) ) if @missing;
my $datetime = Koha::Database->new->schema->storage->datetime_parser->format_datetime( dt_from_string() );
my $datetime = $params->{datetime} ? $params->{datetime} : dt_from_string();
return $class->SUPER::new(
{
borrowernumber => $params->{borrowernumber}, # no longer sending empty string (changed 2023)