Bugzilla – Attachment 167385 Details for
Bug 36367
Remove context stack
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36367: Remove schema_stack
Bug-36367-Remove-schemastack.patch (text/plain), 3.84 KB, created by
Martin Renvoize
on 2024-06-04 12:11:01 UTC
(
hide
)
Description:
Bug 36367: Remove schema_stack
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2024-06-04 12:11:01 UTC
Size:
3.84 KB
patch
obsolete
>From 65918512c826856fc71594daa783b27d9554fc14 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 36367: Remove schema_stack > >Same pattern in Koha::Database > >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > 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.45.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 36367
:
163500
|
163501
|
163502
|
163503
|
163504
|
163505
|
163506
|
163507
|
163508
|
165115
|
165116
|
165117
|
165118
|
165119
|
165120
|
165121
|
165122
|
165123
|
165124
|
165125
|
165126
|
167380
|
167381
|
167382
|
167383
|
167384
| 167385 |
167386
|
167387
|
167388
|
167389
|
167390
|
167391