From 948566e7f36a75a186f96b5ee07b5120a5413ca5 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Thu, 2 Aug 2018 16:11:07 +0000 Subject: [PATCH] Bug 21154: Remove unused subs from C4::Serials Test plan: Run these commands, grep should not return any occurences, prove should return green: git grep GetSerialStatusFromSerialId git grep GetDistributedTo git grep SetDistributedTo git grep SetDistributedto git grep in_array git grep is_barcode_in_use kshell prove t/db_dependent/Serials.t Signed-off-by: Pierre-Luc Lapointe Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens --- C4/Serials.pm | 93 ---------------------------------------- t/db_dependent/Serials.t | 6 +-- 2 files changed, 1 insertion(+), 98 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 0f6256e091..0eb699fc45 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -79,7 +79,6 @@ BEGIN { &GetPreviousSerialid &GetSuppliersWithLateIssues - &GetDistributedTo &SetDistributedTo &getroutinglist &delroutingmember &addroutingmember &reorder_members &check_routing &updateClaim @@ -162,26 +161,6 @@ sub GetSubscriptionHistoryFromSubscriptionId { return $results; } -=head2 GetSerialStatusFromSerialId - -$sth = GetSerialStatusFromSerialId(); -this function returns a statement handle -After this function, don't forget to execute it by using $sth->execute($serialid) -return : -$sth = $dbh->prepare($query). - -=cut - -sub GetSerialStatusFromSerialId { - my $dbh = C4::Context->dbh; - my $query = qq| - SELECT status - FROM serial - WHERE serialid = ? - |; - return $dbh->prepare($query); -} - =head2 GetSerialInformation $data = GetSerialInformation($serialid); @@ -843,28 +822,6 @@ sub GetPreviousSerialid { return $return; } - - -=head2 GetDistributedTo - -$distributedto=GetDistributedTo($subscriptionid) -This function returns the field distributedto for the subscription matching subscriptionid - -=cut - -sub GetDistributedTo { - my $dbh = C4::Context->dbh; - my $distributedto; - my ($subscriptionid) = @_; - - return unless ($subscriptionid); - - my $query = "SELECT distributedto FROM subscription WHERE subscriptionid=?"; - my $sth = $dbh->prepare($query); - $sth->execute($subscriptionid); - return ($distributedto) = $sth->fetchrow; -} - =head2 GetNextSeq my ( @@ -1718,26 +1675,6 @@ sub HasSubscriptionExpired { return 0; # Notice that you'll never get here. } -=head2 SetDistributedto - -SetDistributedto($distributedto,$subscriptionid); -This function update the value of distributedto for a subscription given on input arg. - -=cut - -sub SetDistributedto { - my ( $distributedto, $subscriptionid ) = @_; - my $dbh = C4::Context->dbh; - my $query = qq| - UPDATE subscription - SET distributedto=? - WHERE subscriptionid=? - |; - my $sth = $dbh->prepare($query); - $sth->execute( $distributedto, $subscriptionid ); - return; -} - =head2 DelSubscription DelSubscription($subscriptionid) @@ -2187,16 +2124,6 @@ sub abouttoexpire { return 0; } -sub in_array { # used in next sub down - my ( $val, @elements ) = @_; - foreach my $elem (@elements) { - if ( $val == $elem ) { - return 1; - } - } - return 0; -} - =head2 GetFictiveIssueNumber $issueno = GetFictiveIssueNumber($subscription, $publishedate); @@ -2520,26 +2447,6 @@ sub _numeration { return $string; } -=head2 is_barcode_in_use - -Returns number of occurrences of the barcode in the items table -Can be used as a boolean test of whether the barcode has -been deployed as yet - -=cut - -sub is_barcode_in_use { - my $barcode = shift; - my $dbh = C4::Context->dbh; - my $occurrences = $dbh->selectall_arrayref( - 'SELECT itemnumber from items where barcode = ?', - {}, $barcode - - ); - - return @{$occurrences}; -} - =head2 CloseSubscription Close a subscription given a subscriptionid diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index 6e65ee3098..4c0f56a38d 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -18,7 +18,7 @@ use Koha::DateUtils; use Koha::Acquisition::Booksellers; use t::lib::Mocks; use t::lib::TestBuilder; -use Test::More tests => 48; +use Test::More tests => 46; BEGIN { use_ok('C4::Serials'); @@ -139,8 +139,6 @@ my ($serials_count, @serials) = GetSerials($subscriptionid); ok($serials_count > 0, 'Subscription has at least one serial'); my $serial = $serials[0]; -ok(C4::Serials::GetSerialStatusFromSerialId($serial->{serialid}), 'test getting Serial Status From Serial Id'); - isa_ok(C4::Serials::GetSerialInformation($serial->{serialid}), 'HASH', 'test getting Serial Information'); subtest 'Values should not be erased on editing' => sub { @@ -203,8 +201,6 @@ is(C4::Serials::GetSerials2(), undef, 'test getting serials when you enter nothi is(C4::Serials::GetLatestSerials(), undef, 'test getting lastest serials'); -is(C4::Serials::GetDistributedTo(), undef, 'test getting distributed when nothing is entered'); - is(C4::Serials::GetNextSeq(), undef, 'test getting next seq when you enter nothing'); is(C4::Serials::GetSeq(), undef, 'test getting seq when you enter nothing'); -- 2.39.5