Bugzilla – Attachment 42388 Details for
Bug 14778
DBIC should create/own the DB handler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14778: Make sure the dbh returned is checked by DBIC
Bug-14778-Make-sure-the-dbh-returned-is-checked-by.patch (text/plain), 2.44 KB, created by
Jonathan Druart
on 2015-09-04 11:23:56 UTC
(
hide
)
Description:
Bug 14778: Make sure the dbh returned is checked by DBIC
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-09-04 11:23:56 UTC
Size:
2.44 KB
patch
obsolete
>From 55072d5aebb278692ad7b46588b76d33ccaf71c0 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 4 Sep 2015 12:23:44 +0100 >Subject: [PATCH] Bug 14778: Make sure the dbh returned is checked by DBIC > >--- > C4/Context.pm | 16 ++++------------ > Koha/Database.pm | 7 +++---- > 2 files changed, 7 insertions(+), 16 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index bc95baf..e314f5a 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -364,7 +364,6 @@ sub new { > warn "read_config_file($conf_fname) returned undef" if !defined($self->{"config"}); > return if !defined($self->{"config"}); > >- $self->{"dbh"} = undef; # Database handle > $self->{"Zconn"} = undef; # Zebra Connections > $self->{"stopwords"} = undef; # stopwords list > $self->{"marcfromkohafield"} = undef; # the hash with relations between koha table fields and MARC field/subfield >@@ -725,7 +724,7 @@ sub _new_Zconn { > sub _new_dbh > { > >- Koha::Database->schema->storage->dbh; >+ Koha::Database->schema({ new => 1 })->storage->dbh; > } > > =head2 dbh >@@ -751,17 +750,10 @@ sub dbh > my $sth; > > unless ( $params->{new} ) { >- if ( defined($context->{db_driver}) && $context->{db_driver} eq 'mysql' && $context->{"dbh"} ) { >- return $context->{"dbh"}; >- } elsif ( defined($context->{"dbh"}) && $context->{"dbh"}->ping() ) { >- return $context->{"dbh"}; >- } >+ return Koha::Database->schema->storage->dbh; > } > >- # No database handle or it died . Create one. >- $context->{"dbh"} = &_new_dbh(); >- >- return $context->{"dbh"}; >+ return Koha::Database->schema({ new => 1 })->storage->dbh; > } > > =head2 new_dbh >@@ -782,7 +774,7 @@ sub new_dbh > { > my $self = shift; > >- return &_new_dbh(); >+ return &dbh({ new => 1 }); > } > > =head2 set_dbh >diff --git a/Koha/Database.pm b/Koha/Database.pm >index 1502364..014554f 100644 >--- a/Koha/Database.pm >+++ b/Koha/Database.pm >@@ -115,13 +115,12 @@ possibly C<&set_schema>. > > sub schema { > my $self = shift; >- my $sth; >+ my $params = shift; > >- if ( defined( $database->{schema} ) and $database->{schema}->storage->connected() ) { >- return $database->{schema}; >+ unless ( $params->{new} ) { >+ return $database->{schema} if defined $database->{schema}; > } > >- # No database handle or it died . Create one. > $database->{schema} = &_new_schema(); > return $database->{schema}; > } >-- >2.1.0
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 14778
:
42326
|
42388
|
43247
|
43248
|
43249
|
43250
|
43440
|
43631
|
43632
|
43633
|
43634
|
43635
|
43636
|
43637
|
43638
|
43639
|
43640
|
43641
|
43642
|
43643
|
43644
|
43645
|
43834
|
43835
|
43836
|
43837
|
43838
|
43839
|
43840
|
43841
|
43842
|
43843
|
43844
|
43845
|
43846
|
43847
|
43848
|
43849
|
43850
|
43851
|
43852
|
43853
|
43857
|
43858
|
43859
|
43860
|
43861
|
43862
|
43863
|
43864
|
43865
|
43866
|
43867
|
43868
|
43869
|
43870
|
43871
|
43872
|
43873
|
43874
|
43875
|
43876
|
44003