From fcdbd99b274e2c13c7905d04514b10afe0670a13 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 11 Mar 2024 15:12:09 +0100 Subject: [PATCH] Bug 36367: Remove dbh_stack Same pattern, remove dbh stack Signed-off-by: Julian Maurice --- C4/Context.pm | 61 --------------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 4d7dfa5eea..f9b5ccf2bb 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -97,9 +97,6 @@ environment variable to the pathname of a configuration file to use. # file (/etc/koha/koha-conf.xml). # dbh # A handle to the appropriate database for this context. -# dbh_stack -# Used by &set_dbh and &restore_dbh to hold other database -# handles for this context. # Zconn # A connection object for the Zebra server @@ -601,14 +598,8 @@ Returns a database handle connected to the Koha database for the current context. If no connection has yet been made, this method creates one, and connects to the database. -This database handle is cached for future use: if you call -Cdbh> twice, you will get the same handle both -times. If you need a second database handle, use C<&new_dbh> and -possibly C<&set_dbh>. - =cut -#' sub dbh { my $self = shift; @@ -642,58 +633,6 @@ sub new_dbh return &dbh({ new => 1 }); } -=head2 set_dbh - - $my_dbh = C4::Connect->new_dbh; - C4::Connect->set_dbh($my_dbh); - ... - C4::Connect->restore_dbh; - -C<&set_dbh> saves the current database handle on a stack, then sets -the current database handle to C<$my_dbh>. - -C<$my_dbh> is assumed to be a good database handle. - -=cut - -#' -sub set_dbh -{ - my $self = shift; - my $new_dbh = shift; - - # Save the current database handle on the handle stack. - # We assume that $new_dbh is all good: if the caller wants to - # screw himself by passing an invalid handle, that's fine by - # us. - push @{$context->{"dbh_stack"}}, $context->{"dbh"}; - $context->{"dbh"} = $new_dbh; -} - -=head2 restore_dbh - - C4::Context->restore_dbh; - -Restores the database handle saved by an earlier call to -Cset_dbh>. - -=cut - -#' -sub restore_dbh -{ - my $self = shift; - - if ($#{$context->{"dbh_stack"}} < 0) - { - # Stack underflow - die "DBH stack underflow"; - } - - # Pop the old database handle and set it. - $context->{"dbh"} = pop @{$context->{"dbh_stack"}}; -} - =head2 userenv C4::Context->userenv; -- 2.30.2