Bugzilla – Attachment 161055 Details for
Bug 32029
Automatic item modifications by age missing biblio table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32029: (follow-up) tidy
Bug-32029-follow-up-tidy.patch (text/plain), 7.21 KB, created by
Fridolin Somers
on 2024-01-16 08:48:05 UTC
(
hide
)
Description:
Bug 32029: (follow-up) tidy
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2024-01-16 08:48:05 UTC
Size:
7.21 KB
patch
obsolete
>From 51c5be073473605b0ab75639299e342db5a4f41e Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Tue, 16 Jan 2024 09:22:30 +0100 >Subject: [PATCH] Bug 32029: (follow-up) tidy > >--- > C4/Items.pm | 44 +++++++++---------- > .../Items/AutomaticItemModificationByAge.t | 8 ++-- > tools/automatic_item_modification_by_age.pl | 19 ++++---- > 3 files changed, 37 insertions(+), 34 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 10662ac854..d2fa257ef5 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -1560,24 +1560,25 @@ sub PrepareItemrecordDisplay { > } > > sub ToggleNewStatus { >- my ( $params ) = @_; >- my @rules = @{ $params->{rules} }; >+ my ($params) = @_; >+ my @rules = @{ $params->{rules} }; > my $report_only = $params->{report_only}; > > my $dbh = C4::Context->dbh; > my @errors; >- my @item_columns = map { "items.$_" } Koha::Items->columns; >+ my @item_columns = map { "items.$_" } Koha::Items->columns; > my @biblioitem_columns = map { "biblioitems.$_" } Koha::Biblioitems->columns; >- my @biblio_columns = map { "biblio.$_" } Koha::Biblios->columns; >+ my @biblio_columns = map { "biblio.$_" } Koha::Biblios->columns; > my $report; >- for my $rule ( @rules ) { >+ for my $rule (@rules) { > my $age = $rule->{age}; >+ > # Default to using items.dateaccessioned if there's an old item modification rule > # missing an agefield value >- my $agefield = $rule->{agefield} ? $rule->{agefield} : 'items.dateaccessioned'; >- my $conditions = $rule->{conditions}; >+ my $agefield = $rule->{agefield} ? $rule->{agefield} : 'items.dateaccessioned'; >+ my $conditions = $rule->{conditions}; > my $substitutions = $rule->{substitutions}; >- foreach ( @$substitutions ) { >+ foreach (@$substitutions) { > ( $_->{item_field} ) = ( $_->{field} =~ /items\.(.*)/ ); > } > my @params; >@@ -1589,18 +1590,15 @@ sub ToggleNewStatus { > LEFT JOIN biblio ON biblio.biblionumber = biblioitems.biblionumber > WHERE 1 > |; >- for my $condition ( @$conditions ) { >+ for my $condition (@$conditions) { > next unless $condition->{field}; >- if ( >- grep { $_ eq $condition->{field} } @item_columns >- or grep { $_ eq $condition->{field} } @biblioitem_columns >- or grep { $_ eq $condition->{field} } @biblio_columns >- ) { >+ if ( grep { $_ eq $condition->{field} } @item_columns >+ or grep { $_ eq $condition->{field} } @biblioitem_columns >+ or grep { $_ eq $condition->{field} } @biblio_columns ) >+ { > if ( $condition->{value} =~ /\|/ ) { > my @values = split /\|/, $condition->{value}; >- $query .= qq| AND $condition->{field} IN (| >- . join( ',', ('?') x scalar @values ) >- . q|)|; >+ $query .= qq| AND $condition->{field} IN (| . join( ',', ('?') x scalar @values ) . q|)|; > push @params, @values; > } else { > $query .= qq| AND $condition->{field} = ?|; >@@ -1613,16 +1611,18 @@ sub ToggleNewStatus { > push @params, $age; > } > my $sth = $dbh->prepare($query); >- $sth->execute( @params ); >+ $sth->execute(@params); > while ( my $values = $sth->fetchrow_hashref ) { > my $biblionumber = $values->{biblionumber}; >- my $itemnumber = $values->{itemnumber}; >- my $item = Koha::Items->find($itemnumber); >- for my $substitution ( @$substitutions ) { >+ my $itemnumber = $values->{itemnumber}; >+ my $item = Koha::Items->find($itemnumber); >+ for my $substitution (@$substitutions) { > my $field = $substitution->{item_field}; > my $value = $substitution->{value}; > next unless $substitution->{field}; >- next if ( defined $values->{ $substitution->{item_field} } and $values->{ $substitution->{item_field} } eq $substitution->{value} ); >+ next >+ if ( defined $values->{ $substitution->{item_field} } >+ and $values->{ $substitution->{item_field} } eq $substitution->{value} ); > $item->$field($value); > push @{ $report->{$itemnumber} }, $substitution; > } >diff --git a/t/db_dependent/Items/AutomaticItemModificationByAge.t b/t/db_dependent/Items/AutomaticItemModificationByAge.t >index 51b98f9489..a1c6f73004 100755 >--- a/t/db_dependent/Items/AutomaticItemModificationByAge.t >+++ b/t/db_dependent/Items/AutomaticItemModificationByAge.t >@@ -46,9 +46,9 @@ $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); > > my $record = MARC::Record->new(); > $record->append_fields( >- MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), >- MARC::Field->new('245', ' ', ' ', a => 'Silence in the library', h => 'Book'), >- MARC::Field->new('942', ' ', ' ', c => 'ITEMTYPE_T'), >+ MARC::Field->new( '100', ' ', ' ', a => 'Moffat, Steven' ), >+ MARC::Field->new( '245', ' ', ' ', a => 'Silence in the library', h => 'Book' ), >+ MARC::Field->new( '942', ' ', ' ', c => 'ITEMTYPE_T' ), > ); > my ($biblionumber, undef) = C4::Biblio::AddBiblio($record, $frameworkcode); > >@@ -344,7 +344,7 @@ is( $modified_item->new_status, 'agefield_new_value', q|ToggleNewStatus: Age = 2 > { > field => 'items.new_status', > value => 'new_updated_value_biblio', >- }, >+ }, > ], > age => '0', > }, >diff --git a/tools/automatic_item_modification_by_age.pl b/tools/automatic_item_modification_by_age.pl >index 2f4428b61e..ed3b84611a 100755 >--- a/tools/automatic_item_modification_by_age.pl >+++ b/tools/automatic_item_modification_by_age.pl >@@ -114,17 +114,20 @@ if ( $@ ) { > exit; > } > >-my @item_fields = map { "items.$_" } Koha::Items->columns; >+my @item_fields = map { "items.$_" } Koha::Items->columns; > my @biblioitem_fields = map { "biblioitems.$_" } Koha::Biblioitems->columns; >-my @biblio_fields = map { "biblio.$_" } Koha::Biblios->columns; >-my @age_fields = ('items.dateaccessioned', 'items.replacementpricedate', 'items.datelastborrowed', 'items.datelastseen', 'items.damaged_on', 'items.itemlost_on', 'items.withdrawn_on'); >+my @biblio_fields = map { "biblio.$_" } Koha::Biblios->columns; >+my @age_fields = ( >+ 'items.dateaccessioned', 'items.replacementpricedate', 'items.datelastborrowed', 'items.datelastseen', >+ 'items.damaged_on', 'items.itemlost_on', 'items.withdrawn_on' >+); > $template->param( >- op => $op, >- messages => \@messages, >- agefields => [ @age_fields ], >- condition_fields => [ @item_fields, @biblioitem_fields, @biblio_fields ], >+ op => $op, >+ messages => \@messages, >+ agefields => [@age_fields], >+ condition_fields => [ @item_fields, @biblioitem_fields, @biblio_fields ], > substitution_fields => \@item_fields, >- rules => $rules, >+ rules => $rules, > ); > > output_html_with_http_headers $cgi, $cookie, $template->output; >-- >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 32029
:
142752
|
151073
|
159574
|
159575
|
160977
|
161053
|
161054
|
161055
|
161489