Bugzilla – Attachment 182180 Details for
Bug 29074
DefaultHoldExpirationdatePeriod blank value interpreted as zero
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29074: Do not set default expiration date for hold if DefaultHoldExpirationdatePeriod is left blank
Bug-29074-Do-not-set-default-expiration-date-for-h.patch (text/plain), 4.39 KB, created by
Martin Renvoize (ashimema)
on 2025-05-09 14:20:21 UTC
(
hide
)
Description:
Bug 29074: Do not set default expiration date for hold if DefaultHoldExpirationdatePeriod is left blank
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-05-09 14:20:21 UTC
Size:
4.39 KB
patch
obsolete
>From 075258e43eadf48d783dc3b0e23cba9aa03d703c Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Tue, 22 Apr 2025 09:17:19 +0300 >Subject: [PATCH] Bug 29074: Do not set default expiration date for hold if > DefaultHoldExpirationdatePeriod is left blank > >If DefaultHoldExpirationdate is on and DefaultHoldExpirationdatePeriod >is blank, the blank is treated as a zero and all holds are created >with an expiration date of today. > >This patch changes expiration dates storing so that if >DefaultHoldExpirationdatePeriod is left blank, expiration date is not >set. Users are informed about this with a note in syspref. > >To test: >1. Set DefaultHoldExpirationdate on but leave >DefaultHoldExpirationdatePeriod blank. >2. Add hold for patron. >=> Note that expiration date is set as today. >3. Apply this patch >=> Confirm following note is now added after sysprefs: >"NOTE: If DefaultHoldExpirationdatePeriod is left blank >default expiration date is not set." >4. Add new hold for patron. >=> Note that expiration date is not set. > >Also prove t/db_dependent/Hold.t. > >Sponsored-by: Koha-Suomi Oy >Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > Koha/Hold.pm | 8 +++++-- > .../admin/preferences/circulation.pref | 1 + > t/db_dependent/Hold.t | 22 ++++++++++++++++++- > 3 files changed, 28 insertions(+), 3 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index b3bf4a02b76..8f0cd75ac2f 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -980,10 +980,14 @@ sub store { > sub _set_default_expirationdate { > my $self = shift; > >- my $period = C4::Context->preference('DefaultHoldExpirationdatePeriod') || 0; >+ my $period = C4::Context->preference('DefaultHoldExpirationdatePeriod'); > my $timeunit = C4::Context->preference('DefaultHoldExpirationdateUnitOfTime') || 'days'; > >- $self->expirationdate( dt_from_string( $self->reservedate )->add( $timeunit => $period ) ); >+ if ( defined C4::Context->preference('DefaultHoldExpirationdatePeriod') >+ && C4::Context->preference('DefaultHoldExpirationdatePeriod') ne '' ) >+ { >+ $self->expirationdate( dt_from_string( $self->reservedate )->add( $timeunit => $period ) ); >+ } > } > > =head3 _move_to_old >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index 291c6ccec6b..c50abdfa3d3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -1078,6 +1078,7 @@ Circulation: > months: months > years: years > - from reserve date. >+ - <br><strong>NOTE:</strong> If <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=DefaultHoldExpirationdatePeriod">DefaultHoldExpirationdatePeriod</a> is left blank, no default expiration date is set.</br> > - > - When placing a hold via the staff interface default the pickup location to the > - pref: DefaultHoldPickupLocation >diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t >index 23e42c4291a..21572e476c8 100755 >--- a/t/db_dependent/Hold.t >+++ b/t/db_dependent/Hold.t >@@ -160,7 +160,7 @@ $schema->storage->txn_rollback(); > > subtest "store() tests" => sub { > >- plan tests => 7; >+ plan tests => 8; > > $schema->storage->txn_begin(); > >@@ -292,6 +292,26 @@ subtest "store() tests" => sub { > 'Expiration date set same as patron_expiration_date after reverting holds waiting status.' > ); > >+ # Do not set expiration date for hold if no period is set >+ t::lib::Mocks::mock_preference( 'DefaultHoldExpirationdatePeriod', '' ); >+ $hold = Koha::Hold->new( >+ { >+ biblionumber => $biblio->biblionumber, >+ itemnumber => $item->id, >+ reservedate => '2022-12-14', >+ waitingdate => '2022-12-14', >+ borrowernumber => $borrower->borrowernumber, >+ branchcode => $library->branchcode, >+ suspend => 0, >+ } >+ )->store; >+ $hold->discard_changes; >+ >+ is( >+ $hold->expirationdate, >+ undef, 'Expiration date not set if "DefaultHoldExpirationdatePeriod" is left empty.' >+ ); >+ > $schema->storage->txn_rollback(); > }; > >-- >2.49.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29074
:
144572
|
154484
|
154813
|
157068
|
157069
|
157128
|
157129
|
180628
|
180629
|
180630
|
181237
|
181249
| 182180