From 6a155d75f212abc3a02a2c35d385ea4a5100d5c9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 20 Nov 2012 15:57:13 +0100 Subject: [PATCH] Bug 9116: Remove some useless tmp variables Some variables are useless in C4::Items::PrepareItemrecordDisplay. This patch removes its. Test plan: Syspref AcqCreateItem = "receive an order" and try to receive an order. Check there is no regression. Signed-off-by: Kyle M Hall Signed-off-by: Marcel de Rooy Signed-off-by: Jared Camins-Esakov --- C4/Items.pm | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 012ec8a730..dbd06b60e2 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -2645,52 +2645,39 @@ sub PrepareItemrecordDisplay { $defaultvalue = $tagslib->{$tag}->{$subfield}->{defaultvalue} unless $defaultvalue; if ( !defined $defaultvalue ) { $defaultvalue = q||; + } else { + $defaultvalue =~ s/"/"/g; } - $defaultvalue =~ s/"/"/g; # search for itemcallnumber if applicable if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' && C4::Context->preference('itemcallnumber') ) { my $CNtag = substr( C4::Context->preference('itemcallnumber'), 0, 3 ); my $CNsubfield = substr( C4::Context->preference('itemcallnumber'), 3, 1 ); - if ($itemrecord) { - my $temp = $itemrecord->field($CNtag); - if ($temp) { - $defaultvalue = $temp->subfield($CNsubfield); - } + if ( $itemrecord and my $field = $itemrecord->field($CNtag) ) { + $defaultvalue = $field->subfield($CNsubfield); } } if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' && $defaultvalues && $defaultvalues->{'callnumber'} ) { - my $temp; - if ($itemrecord) { - $temp = $itemrecord->field($subfield); - } - unless ($temp) { - $defaultvalue = $defaultvalues->{'callnumber'} if $defaultvalues; + if( $itemrecord and $defaultvalues and not $itemrecord->field($subfield) ){ + $defaultvalue = $defaultvalues->{callnumber}; } } if ( ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.holdingbranch' || $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.homebranch' ) && $defaultvalues && $defaultvalues->{'branchcode'} ) { - my $temp; - if ($itemrecord) { - $temp = $itemrecord->field($subfield); - } - unless ($temp) { - $defaultvalue = $defaultvalues->{branchcode} if $defaultvalues; + if ( $itemrecord and $defaultvalues and not $itemrecord->field($subfield) ) { + $defaultvalue = $defaultvalues->{branchcode}; } } if ( ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.location' ) && $defaultvalues && $defaultvalues->{'location'} ) { - my $temp; # make perlcritic happy :) - $temp = $itemrecord->field($subfield) if ($itemrecord); - - unless ($temp) { - $defaultvalue = $defaultvalues->{location} if $defaultvalues; + if ( $itemrecord and $defaultvalues and not $itemrecord->field($subfield) ) { + $defaultvalue = $defaultvalues->{location}; } } if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) { @@ -2772,9 +2759,8 @@ sub PrepareItemrecordDisplay { # opening plugin my $plugin = C4::Context->intranetdir . "/cataloguing/value_builder/" . $tagslib->{$tag}->{$subfield}->{'value_builder'}; if (do $plugin) { - my $temp; - my $extended_param = plugin_parameters( $dbh, $temp, $tagslib, $subfield_data{id}, undef ); - my ( $function_name, $javascript ) = plugin_javascript( $dbh, $temp, $tagslib, $subfield_data{id}, undef ); + my $extended_param = plugin_parameters( $dbh, undef, $tagslib, $subfield_data{id}, undef ); + my ( $function_name, $javascript ) = plugin_javascript( $dbh, undef, $tagslib, $subfield_data{id}, undef ); $subfield_data{random} = int(rand(1000000)); # why do we need 2 different randoms? $subfield_data{marc_value} = qq[