Bugzilla – Attachment 188043 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]
Code commit to upgrade this feature
0001-Bug-29326-_ALL_-should-not-override-other-rules-in-U.patch (text/plain), 4.99 KB, created by
Olli-Antti Kivilahti
on 2025-10-17 04:02:41 UTC
(
hide
)
Description:
Code commit to upgrade this feature
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2025-10-17 04:02:41 UTC
Size:
4.99 KB
patch
obsolete
>From 62a09afe9a2954e22d54e95e8001562fcf05ae7f 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. >--- > lib/Koha/Item.pm | 100 +++++++++++++++++++++-------------------------- > 1 file changed, 44 insertions(+), 56 deletions(-) > >diff --git a/lib/Koha/Item.pm b/lib/Koha/Item.pm >index 5012584..98170ac 100644 >--- a/lib/Koha/Item.pm >+++ b/lib/Koha/Item.pm >@@ -2704,6 +2704,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'); >@@ -2712,66 +2733,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_'}); > } > } >- return $messages; > } > >+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 undef; >+} > > =head3 z3950_status > >-- >2.43.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 29326
:
188043
|
188269
|
188270
|
188271
|
188272
|
188273
|
188274
|
188275
|
188276
|
188277
|
188278
|
189063