Bugzilla – Attachment 135236 Details for
Bug 28739
Objects in notices should restrict the methods that can be called
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28739: Execute the letter processing inside a transaction
Bug-28739-Execute-the-letter-processing-inside-a-t.patch (text/plain), 2.35 KB, created by
Martin Renvoize (ashimema)
on 2022-05-20 10:31:26 UTC
(
hide
)
Description:
Bug 28739: Execute the letter processing inside a transaction
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-05-20 10:31:26 UTC
Size:
2.35 KB
patch
obsolete
>From d51a32ddb1c370c80391a87921f44e3bd0667278 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 13 Oct 2021 14:46:08 +0200 >Subject: [PATCH] Bug 28739: Execute the letter processing inside a transaction > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Letters.pm | 3 +++ > t/db_dependent/Letters/TemplateToolkit.t | 23 ++++++++++++++++++++++- > 2 files changed, 25 insertions(+), 1 deletion(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 56ea08dd22..01935ff88f 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1608,7 +1608,10 @@ sub _process_tt { > $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|; > > 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; > > return $output; > } >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index c8fb64f0dd..594f5689f8 100755 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -19,7 +19,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 29; >+use Test::More tests => 30; > use Test::MockModule; > use Test::Warn; > >@@ -1188,6 +1188,27 @@ EOF > is( $letter->{content}, $expected_content ); > }; > >+subtest 'Execute TT process in a DB transaction' => sub { >+ plan tests => 2; >+ my $code = 'TEST_TXN'; >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $template = <<EOF; >+=[% branch.branchcode %]= >+[%~ branch.delete ~%] >+EOF >+ reset_template({ template => $template, code => $code, module => 'test' }); >+ my $letter = GetPreparedLetter( >+ module => 'test', >+ letter_code => $code, >+ tables => { >+ branches => $library->branchcode, >+ } >+ ); >+ my $branchcode = $library->branchcode; >+ like($letter->{content}, qr{=$branchcode=}, 'content generated with the library'); >+ is( ref($library->get_from_storage), 'Koha::Library', 'calling ->delete on the object has not been comitted'); >+}; >+ > sub reset_template { > my ( $params ) = @_; > my $template = $params->{template}; >-- >2.20.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 28739
:
123104
|
123105
|
126190
|
130482
|
135236
|
136804