Bugzilla – Attachment 163043 Details for
Bug 36149
userenv stored in plack worker's memory and survive from one request to another
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36149: Remove schema_stack
Bug-36149-Remove-schemastack.patch (text/plain), 3.72 KB, created by
Jonathan Druart
on 2024-03-11 14:25:08 UTC
(
hide
)
Description:
Bug 36149: Remove schema_stack
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-03-11 14:25:08 UTC
Size:
3.72 KB
patch
obsolete
>From c4fe7babd31feafd8411952d7f2131182c7be6b7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 8 Mar 2024 14:33:29 +0100 >Subject: [PATCH] Bug 36149: Remove schema_stack > >Same pattern in Koha::Database >--- > Koha/Database.pm | 77 +--------------------------------- > t/db_dependent/Koha_Database.t | 7 +--- > 2 files changed, 2 insertions(+), 82 deletions(-) > >diff --git a/Koha/Database.pm b/Koha/Database.pm >index 87bc53de7f2..8457c18e801 100644 >--- a/Koha/Database.pm >+++ b/Koha/Database.pm >@@ -166,8 +166,7 @@ creates one, and connects to the database. > > This database handle is cached for future use: if you call > C<$database-E<gt>schema> twice, you will get the same handle both >-times. If you need a second database handle, use C<&new_schema> and >-possibly C<&set_schema>. >+times. > > =cut > >@@ -182,80 +181,6 @@ sub schema { > return $database->{schema}; > } > >-=head2 new_schema >- >- $schema = $database->new_schema; >- >-Creates a new connection to the Koha database for the current context, >-and returns the database handle (a C<DBI::db> object). >- >-The handle is not saved anywhere: this method is strictly a >-convenience function; the point is that it knows which database to >-connect to so that the caller doesn't have to know. >- >-=cut >- >-#' >-sub new_schema { >- my $self = shift; >- >- return &_new_schema(); >-} >- >-=head2 set_schema >- >- $my_schema = $database->new_schema; >- $database->set_schema($my_schema); >- ... >- $database->restore_schema; >- >-C<&set_schema> and C<&restore_schema> work in a manner analogous to >-C<&set_context> and C<&restore_context>. >- >-C<&set_schema> saves the current database handle on a stack, then sets >-the current database handle to C<$my_schema>. >- >-C<$my_schema> is assumed to be a good database handle. >- >-=cut >- >-sub set_schema { >- my $self = shift; >- my $new_schema = shift; >- >- # Save the current database handle on the handle stack. >- # We assume that $new_schema is all good: if the caller wants to >- # screw himself by passing an invalid handle, that's fine by >- # us. >- push @{ $database->{schema_stack} }, $database->{schema}; >- $database->{schema} = $new_schema; >-} >- >-=head2 restore_schema >- >- $database->restore_schema; >- >-Restores the database handle saved by an earlier call to >-C<$database-E<gt>set_schema>. >- >-=cut >- >-sub restore_schema { >- my $self = shift; >- >- if ( $#{ $database->{schema_stack} } < 0 ) { >- >- # Stack underflow >- die "SCHEMA stack underflow"; >- } >- >- # Pop the old database handle and set it. >- $database->{schema} = pop @{ $database->{schema_stack} }; >- >- # FIXME - If it is determined that restore_context should >- # return something, then this function should, too. >-} >- > =head2 db_scheme2dbi > > my $dbd_driver_name = Koha::Database::db_scheme2dbi($scheme); >diff --git a/t/db_dependent/Koha_Database.t b/t/db_dependent/Koha_Database.t >index d950cb9ad7e..dd51feb707e 100755 >--- a/t/db_dependent/Koha_Database.t >+++ b/t/db_dependent/Koha_Database.t >@@ -4,7 +4,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 12; >+use Test::More tests => 9; > > BEGIN { > use_ok('Koha::Database'); >@@ -24,11 +24,6 @@ is( $another_schema->storage->_conn_pid, $schema->storage->_conn_pid, 'Getting a > $another_schema = Koha::Database->new->schema(); > is( $another_schema->storage->_conn_pid, $schema->storage->_conn_pid, 'Getting another schema should return the same one, it has correctly been cached' ); > >-my $new_schema; >-ok( $new_schema = $database->new_schema(), 'Try to get a new schema' ); >-ok( $database->set_schema($new_schema), 'Switch to new schema' ); >-ok( $database->restore_schema(), 'Switch back' ); >- > # run in a transaction > $schema->storage->txn_begin(); > >-- >2.34.1
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 36149
:
163039
|
163040
|
163041
|
163042
|
163043
|
163402
|
163403
|
163404
|
163406
|
163407
|
163409
|
163412
|
163499
|
164145
|
164146
|
164555
|
164567
|
164568
|
164569