Bugzilla – Attachment 188270 Details for
Bug 29326
_ALL_ should not override other rules in UpdateItemLocationOnCheckin
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29326 - _ALL_ should not override other rules in UpdateItemLocationOnCheckin. Backend.
Bug-29326---ALL-should-not-override-other-rules-in.patch (text/plain), 4.98 KB, created by
Lari Taskula
on 2025-10-22 08:12:10 UTC
(
hide
)
Description:
Bug 29326 - _ALL_ should not override other rules in UpdateItemLocationOnCheckin. Backend.
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2025-10-22 08:12:10 UTC
Size:
4.98 KB
patch
obsolete
>From 38b12baadfbd7cdc932bae0463ad99080ecfc004 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <Olli-Antti.Kivilahti@Hypernova.fi> >Date: Fri, 17 Oct 2025 06:58:49 +0300 >Subject: [PATCH] Bug 29326 - _ALL_ should not override other rules in > UpdateItemLocationOnCheckin. Backend. > >Refactored for a more efficient testing of rules. >Added _DEFAULT_ to fall back to if _ALL_ or a specific location rule is not defined. >--- > Koha/Item.pm | 102 +++++++++++++++++++++++---------------------------- > 1 file changed, 46 insertions(+), 56 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 05d2e97570e..96a97f9f6d8 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -2783,6 +2783,27 @@ FIXME: It should return I<$self>. See bug 35270. > sub location_update_trigger { > my ( $self, $action ) = @_; > >+ if (my $new_location = $self->_check_location_update_rules($action)) { >+ my $messages = { >+ 'ItemLocationUpdated' => { >+ from => $self->location, >+ to => $new_location, >+ } >+ }; >+ $self->location($new_location)->store( >+ { >+ log_action => 0, >+ skip_record_index => 1, >+ skip_holds_queue => 1 >+ } >+ ); >+ return $messages; >+ } >+ return undef; >+} >+ >+sub _check_location_update_rules { >+ my ($self, $action) = @_; > my ( $update_loc_rules, $messages ); > if ( $action eq 'checkin' ) { > $update_loc_rules = C4::Context->yaml_preference('UpdateItemLocationOnCheckin'); >@@ -2791,64 +2812,33 @@ sub location_update_trigger { > } > > if ($update_loc_rules) { >- if ( defined $update_loc_rules->{_ALL_} ) { >- if ( $update_loc_rules->{_ALL_} eq '_PERM_' ) { >- $update_loc_rules->{_ALL_} = $self->permanent_location; >- } >- if ( $update_loc_rules->{_ALL_} eq '_BLANK_' ) { >- $update_loc_rules->{_ALL_} = ''; >- } >- if ( >- ( defined $self->location && $self->location ne $update_loc_rules->{_ALL_} ) >- || ( !defined $self->location >- && $update_loc_rules->{_ALL_} ne "" ) >- ) >- { >- $messages->{'ItemLocationUpdated'} = >- { from => $self->location, to => $update_loc_rules->{_ALL_} }; >- $self->location( $update_loc_rules->{_ALL_} )->store( >- { >- log_action => 0, >- skip_record_index => 1, >- skip_holds_queue => 1 >- } >- ); >- } >- } else { >- foreach my $key ( keys %$update_loc_rules ) { >- if ( $update_loc_rules->{$key} eq '_PERM_' ) { >- $update_loc_rules->{$key} = $self->permanent_location; >- } elsif ( $update_loc_rules->{$key} eq '_BLANK_' ) { >- $update_loc_rules->{$key} = ''; >- } >- if ( >- ( >- defined $self->location >- && $self->location eq $key >- && $self->location ne $update_loc_rules->{$key} >- ) >- || ( $key eq '_BLANK_' >- && ( !defined $self->location || $self->location eq '' ) >- && $update_loc_rules->{$key} ne '' ) >- ) >- { >- $messages->{'ItemLocationUpdated'} = { >- from => $self->location, >- to => $update_loc_rules->{$key} >- }; >- $self->location( $update_loc_rules->{$key} )->store( >- { >- log_action => 0, >- skip_record_index => 1, >- skip_holds_queue => 1 >- } >- ); >- last; >- } >- } >+ if (defined($update_loc_rules->{'_ALL_'})) { >+ return $self->_check_location_update_rule($update_loc_rules->{'_ALL_'}); >+ } >+ elsif (defined($update_loc_rules->{$self->location//''})) { >+ return $self->_check_location_update_rule($update_loc_rules->{$self->location}); > } >+ elsif (defined($update_loc_rules->{'_DEFAULT_'})) { >+ return $self->_check_location_update_rule($update_loc_rules->{'_DEFAULT_'}); >+ } >+ } >+} >+ >+ >+sub _check_location_update_rule { >+ my ($self, $update_loc_rule) = @_; >+ >+ if ($update_loc_rule eq '_PERM_') { >+ $update_loc_rule = $self->permanent_location; >+ } >+ if ($update_loc_rule eq '_BLANK_') { >+ $update_loc_rule = ''; >+ } >+ if ((defined($self->location) && $self->location ne $update_loc_rule) || >+ (not(defined($self->location)) && $update_loc_rule ne "" )) { >+ return $update_loc_rule; > } >- return $messages; >+ return undef; > } > > =head3 z3950_status >-- >2.34.1
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 29326
:
188043
|
188269
| 188270 |
188271
|
188272
|
188273
|
188274
|
188275
|
188276
|
188277
|
188278
|
189063