Bugzilla – Attachment 21656 Details for
Bug 10611
C4::Context->dbh checks if the DB is still running
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10611: add a "new" parameter to C4::Context->dbh
Bug-10611-add-a-new-parameter-to-C4Context-dbh.patch (text/plain), 2.03 KB, created by
Jonathan Druart
on 2013-09-30 11:48:32 UTC
(
hide
)
Description:
Bug 10611: add a "new" parameter to C4::Context->dbh
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-09-30 11:48:32 UTC
Size:
2.03 KB
patch
obsolete
>From 9df13ec79a3d01f71ccafff800fa0f955bb8921c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 30 Sep 2013 13:40:32 +0200 >Subject: [PATCH] Bug 10611: add a "new" parameter to C4::Context->dbh > >When dbh->disconnect is called and the mysql_auto_reconnect flag is set, >the dbh is not recreated: the old one is used. > >Adding a new flag, we can now force the C4::Context->dbh method to >return a new dbh. >--- > C4/Context.pm | 11 +++++++---- > t/db_dependent/Context.t | 5 +---- > 2 files changed, 8 insertions(+), 8 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 874a9ae..becab7d 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -860,12 +860,15 @@ possibly C<&set_dbh>. > sub dbh > { > my $self = shift; >+ my $params = shift; > my $sth; > >- if ( defined $db_driver && $db_driver eq 'mysql' && $context->{"dbh"} ) { >- return $context->{"dbh"}; >- } elsif ( defined $db_driver && defined($context->{"dbh"}) && $context->{"dbh"}->ping()) { >- return $context->{"dbh"}; >+ unless ( $params->{new} ) { >+ if ( defined $db_driver && $db_driver eq 'mysql' && $context->{"dbh"} ) { >+ return $context->{"dbh"}; >+ } elsif ( defined $db_driver && defined($context->{"dbh"}) && $context->{"dbh"}->ping()) { >+ return $context->{"dbh"}; >+ } > } > > # No database handle or it died . Create one. >diff --git a/t/db_dependent/Context.t b/t/db_dependent/Context.t >index 32ea441..54aefda 100755 >--- a/t/db_dependent/Context.t >+++ b/t/db_dependent/Context.t >@@ -50,9 +50,6 @@ ok($config = $koha->{config}, 'Getting $koha->{config} '); > > diag "Testing syspref caching."; > >-my $dbh = C4::Context->dbh; >-$dbh->disconnect; >- > my $module = new Test::MockModule('C4::Context'); > $module->mock( > '_new_dbh', >@@ -64,7 +61,7 @@ $module->mock( > ); > > my $history; >-$dbh = C4::Context->dbh; >+$dbh = C4::Context->dbh({ new => 1 }); > > $dbh->{mock_add_resultset} = [ ['value'], ['thing1'] ]; > $dbh->{mock_add_resultset} = [ ['value'], ['thing2'] ]; >-- >1.7.10.4
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 10611
:
19765
|
20273
|
21264
|
21655
|
21656
|
21657
|
21667
|
21668
|
21669
|
22103