Bugzilla – Attachment 145863 Details for
Bug 32442
Invalid Template Toolkit in notices can cause errors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32442: (bug 28739 follow-up) Ensure txn is rollbacked
Bug-32442-bug-28739-follow-up-Ensure-txn-is-rollba.patch (text/plain), 2.35 KB, created by
Marcel de Rooy
on 2023-01-31 13:09:45 UTC
(
hide
)
Description:
Bug 32442: (bug 28739 follow-up) Ensure txn is rollbacked
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-01-31 13:09:45 UTC
Size:
2.35 KB
patch
obsolete
>From a96c7b0c7c9735bde8d18aa8c8008eb0279b5893 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 14 Dec 2022 08:42:03 +0100 >Subject: [PATCH] Bug 32442: (bug 28739 follow-up) Ensure txn is rollbacked >Content-Type: text/plain; charset=utf-8 > >If the TT process call is returning false and so the croak is raised, >then the txn is not rollbacked and the txn is not commited either. > >We need to ensure the txn will be correctly rollbacked. > >Test plan: >1. Go to any notice and create some invalid Template Toolkit: > >[% IF ( 1 == 1 %] >test >[% END %] > >2. Save and continue > >3. Logout of Koha and attempt to log back in >=> Without this patch you got >Transaction aborted: DBIx::Class::Storage::DBI::mysql::_exec_svp_release(): DBI Exception: DBD::mysql::db do failed: SAVEPOINT savepoint_4 does not exist at /kohadevbox/koha/Koha/Object.pm line 170 >. Rollback failed: DBIx::Class::Storage::DBI::mysql::_exec_svp_rollback(): DBI Exception: DBD::mysql::db do failed: SAVEPOINT savepoint_3 does not exist at /kohadevbox/koha/Koha/Patron.pm line 363 at /kohadevbox/koha/Koha/Patron.pm line 363 > at /usr/share/perl5/DBIx/Class/Exception.pm line 77 >=> With this patch applied the login works successfully > >QA Note: The test is not testing that the txn is rolledback, I didn't >manage to test that. > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Letters.pm | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 4d60753cc6..3bddc69ecb 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -23,7 +23,7 @@ use Carp qw( carp croak ); > use Template; > use Module::Load::Conditional qw( can_load ); > >-use Try::Tiny qw( catch try ); >+use Try::Tiny; > > use C4::Members; > use C4::Log qw( logaction ); >@@ -1620,8 +1620,13 @@ sub _process_tt { > my $output; > my $schema = Koha::Database->new->schema; > $schema->txn_begin; >- $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error(); >- $schema->txn_rollback; >+ my $processed = try { >+ $template->process( \$content, $tt_params, \$output ); >+ } >+ finally { >+ $schema->txn_rollback; >+ }; >+ croak "ERROR PROCESSING TEMPLATE: " . $template->error() unless $processed; > > return $output; > } >-- >2.30.2
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 32442
:
144564
|
144565
|
144686
|
144687
|
145862
| 145863