From e83a8e5153f71fe07e3fa8ff96644c972367173b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 3 Mar 2014 15:59:30 +0100 Subject: [PATCH] Bug 11023: FIX - condition on biblioitems table does not work If a rule contains a condition on the biblioitems table, the match won't work. This patch fixes this issue. --- C4/Items.pm | 2 +- t/db_dependent/Items/ToggleNewStatus.t | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 0036ede..962ea29 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -3144,7 +3144,7 @@ sub ToggleNewStatus { my $query = q| SELECT items.biblionumber, items.itemnumber FROM items - LEFT JOIN biblioitems ON items.biblioitemnumber = items.itemnumber + LEFT JOIN biblioitems ON biblioitems.biblionumber = items.biblionumber WHERE 1 |; for my $condition ( @$conditions ) { diff --git a/t/db_dependent/Items/ToggleNewStatus.t b/t/db_dependent/Items/ToggleNewStatus.t index 8ea14f7..40d8e4a 100644 --- a/t/db_dependent/Items/ToggleNewStatus.t +++ b/t/db_dependent/Items/ToggleNewStatus.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use Modern::Perl; -use Test::More tests => 15; +use Test::More tests => 16; use MARC::Record; use MARC::Field; use DateTime; @@ -31,6 +31,7 @@ my $record = MARC::Record->new(); $record->append_fields( MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'), + MARC::Field->new('942', ' ', ' ', c => 'ITEMTYPE_T'), ); my ($biblionumber, undef) = C4::Biblio::AddBiblio($record, ''); @@ -258,3 +259,25 @@ C4::Items::ToggleNewStatus( { rules => \@rules } ); $modified_item = C4::Items::GetItem( $itemnumber ); is( $modified_item->{new}, 'new_updated_value', q|ToggleNewStatus: conditions multiple: the 2 conditions match, the new value is updated|); +@rules = ( + { + conditions => [ + { + field => 'biblioitems.itemtype', + value => 'ITEMTYPE_T', + }, + ], + substitutions => [ + { + field => 'items.new', + value => 'another_new_updated_value', + }, + ], + duration => '0', + }, +); + +C4::Items::ToggleNewStatus( { rules => \@rules } ); + +$modified_item = C4::Items::GetItem( $itemnumber ); +is( $modified_item->{new}, 'another_new_updated_value', q|ToggleNewStatus: conditions on biblioitems|); -- 2.1.0