@@ -, +, @@ --- Koha/Database.pm | 11 +---------- Koha/Schema.pm | 2 +- Koha/Storage.pm | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 Koha/Storage.pm --- a/Koha/Database.pm +++ a/Koha/Database.pm @@ -46,16 +46,7 @@ __PACKAGE__->mk_accessors(qw( )); # returns it. sub _new_schema { my $context = C4::Context->new(); - my $db_driver = C4::Context::db_scheme2dbi($context->config("db_scheme")); - - my $db_name = $context->config("database"); - my $db_host = $context->config("hostname"); - my $db_port = $context->config("port") || ''; - my $db_user = $context->config("user"); - my $db_passwd = $context->config("pass"); - my $schema = Koha::Schema->connect( - "DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port", - $db_user, $db_passwd ); + my $schema = Koha::Schema->connect( sub { $context->dbh } ); return $schema; } --- a/Koha/Schema.pm +++ a/Koha/Schema.pm @@ -15,6 +15,6 @@ __PACKAGE__->load_namespaces; # Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oDUxXckmfk6H9YCjW8PZTw +__PACKAGE__->storage_type('Koha::Storage'); -# You can replace this text with custom content, and it will be preserved on regeneration 1; --- a/Koha/Storage.pm +++ a/Koha/Storage.pm @@ -0,0 +1,19 @@ +use utf8; +package Koha::Storage; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +use strict; +use warnings; + +use base 'DBIx::Class::Storage::DBI'; +sub DESTROY { + my $self = shift; + + # destroy just the object if not native to this process/thread + $self->_preserve_foreign_dbh; + + $self->_dbh(undef); +} +1; --