From c97e04e8e79261a5dc2ac78f92a5b331ad6a8b30 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 9 Jul 2016 14:35:08 +0100 Subject: [PATCH] Bug 16889: Remove C4::Members::columns and use Koha::Patrons->columns instead Test plan: Import some patrons (tools/import_borrowers.pl) and make sure it imports the patrons correctly. Signed-off-by: Mark Tompsett Signed-off-by: Kyle M Hall Signed-off-by: Kyle M Hall --- C4/Members.pm | 35 -------------------------------- t/db_dependent/Members/columns.t | 24 ---------------------- tools/import_borrowers.pl | 3 ++- 3 files changed, 2 insertions(+), 60 deletions(-) delete mode 100644 t/db_dependent/Members/columns.t diff --git a/C4/Members.pm b/C4/Members.pm index cd1e78ec78..d5c76039f7 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -551,41 +551,6 @@ sub GetMemberIssuesAndFines { } -=head2 columns - - my @columns = C4::Member::columns(); - -Returns an array of borrowers' table columns on success, -and an empty array on failure. - -=cut - -sub columns { - - # Pure ANSI SQL goodness. - my $sql = 'SELECT * FROM borrowers WHERE 1=0;'; - - # Get the database handle. - my $dbh = C4::Context->dbh; - - # Run the SQL statement to load STH's readonly properties. - my $sth = $dbh->prepare($sql); - my $rv = $sth->execute(); - - # This only fails if the table doesn't exist. - # This will always be called AFTER an install or upgrade, - # so borrowers will exist! - my @data; - if ($sth->{NUM_OF_FIELDS}>0) { - @data = @{$sth->{NAME}}; - } - else { - @data = (); - } - return @data; -} - - =head2 ModMember my $success = ModMember(borrowernumber => $borrowernumber, diff --git a/t/db_dependent/Members/columns.t b/t/db_dependent/Members/columns.t deleted file mode 100644 index 5b7ffe0200..0000000000 --- a/t/db_dependent/Members/columns.t +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/perl -# -# This is to test C4/Members -# It requires a working Koha database with the sample data - -use Modern::Perl; - -use Test::More tests => 2; - -BEGIN { - use_ok('C4::Members'); -} - -my @borrowers_columns = C4::Members::columns; -ok( - $#borrowers_columns > 1, - 'C4::Member->column returned a reasonable number of columns (' - . ( $#borrowers_columns + 1 ) . ')' - ) - or diag( -'WARNING: Check that the borrowers table exists and has the correct fields defined.' - ); - -exit; diff --git a/tools/import_borrowers.pl b/tools/import_borrowers.pl index 8c03274fcf..e1754e6efe 100755 --- a/tools/import_borrowers.pl +++ b/tools/import_borrowers.pl @@ -48,6 +48,7 @@ use C4::Members::Messaging; use C4::Reports::Guided; use C4::Templates; use Koha::Patron::Debarments; +use Koha::Patrons; use Koha::DateUtils; use Text::CSV; @@ -61,7 +62,7 @@ use CGI qw ( -utf8 ); my (@errors, @feedback); my $extended = C4::Context->preference('ExtendedPatronAttributes'); my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences'); -my @columnkeys = C4::Members::columns(); +my @columnkeys = Koha::Patrons->columns(); @columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } @columnkeys; if ($extended) { push @columnkeys, 'patron_attributes'; -- 2.39.5