Bugzilla – Attachment 19250 Details for
Bug 8798
Add the use of DBIx::Class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
DBIx::Class tests: replacing GetBranchName by it's DBIx::Class equivalent
DBIxClass-tests-replacing-GetBranchName-by-its-DBI.patch (text/plain), 1.86 KB, created by
Paul Poulain
on 2013-06-26 19:00:35 UTC
(
hide
)
Description:
DBIx::Class tests: replacing GetBranchName by it's DBIx::Class equivalent
Filename:
MIME Type:
Creator:
Paul Poulain
Created:
2013-06-26 19:00:35 UTC
Size:
1.86 KB
patch
obsolete
>From 07999bac4371450a6aecf9f0e51358d7be471717 Mon Sep 17 00:00:00 2001 >From: Paul Poulain <paul.poulain@biblibre.com> >Date: Wed, 26 Jun 2013 20:40:56 +0200 >Subject: [PATCH] DBIx::Class tests: replacing GetBranchName by it's > DBIx::Class equivalent > >In this patch, I choose to overload the C4/Branch.pm/GetBranchName by it's DBIx::Class equivalent > >It's just a POC, no need to commit this patch. >the question behind the patch is: should we > * REMOVE GetBranchName by replacing all the calls by Koha::BusinessLogic::Branch->read({'branchcode' => $branchcode})->first->branchname; > * overload the sub and make it die later > >I think the 1st will require more effort, but better, while the second requires less effort, but result in much less code cleaning > >My preference would go to the 1st option. > >http://bugs.koha-community.org/show_bug.cgi?id=8798 >--- > C4/Branch.pm | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > >diff --git a/C4/Branch.pm b/C4/Branch.pm >index 5770f7b..34f7532 100644 >--- a/C4/Branch.pm >+++ b/C4/Branch.pm >@@ -21,6 +21,8 @@ use strict; > require Exporter; > use C4::Context; > >+use Koha::BusinessLogic::Branch; >+ > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); > > BEGIN { >@@ -177,13 +179,8 @@ sub GetBranchesLoop { # since this is what most pages want anyway > > sub GetBranchName { > my ($branchcode) = @_; >- my $dbh = C4::Context->dbh; >- my $sth; >- $sth = $dbh->prepare("Select branchname from branches where branchcode=?"); >- $sth->execute($branchcode); >- my $branchname = $sth->fetchrow_array; >- $sth->finish; >- return ($branchname); >+ return "" unless $branchcode; #FIXME ? sometimes GetBranchName is called without branchcode, we must return immediatly to avoid an arror in ->first->branchname >+ return Koha::BusinessLogic::Branch->read({'branchcode' => $branchcode})->first->branchname; > } > > =head2 ModBranch >-- >1.7.9.5
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 8798
:
12403
|
12405
|
12429
|
12439
|
12442
|
12443
|
12453
|
12477
|
12478
|
12480
|
12481
|
12506
|
12520
|
12521
|
12538
|
17581
|
17582
|
17583
|
17584
|
17585
|
17586
|
19134
|
19137
|
19138
|
19139
|
19140
|
19141
|
19248
|
19249
|
19250
|
19251