View | Details | Raw Unified | Return to bug 28739
Collapse All | Expand All

(-)a/C4/Letters.pm (+3 lines)
Lines 1639-1645 sub _process_tt { Link Here
1639
    $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|;
1639
    $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|;
1640
1640
1641
    my $output;
1641
    my $output;
1642
    my $schema = Koha::Database->new->schema;
1643
    $schema->txn_begin;
1642
    $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
1644
    $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
1645
    $schema->txn_rollback;
1643
1646
1644
    return $output;
1647
    return $output;
1645
}
1648
}
(-)a/Koha/Object.pm (+17 lines)
Lines 374-379 sub add_message { Link Here
374
    my ( $self, $params ) = @_;
374
    my ( $self, $params ) = @_;
375
375
376
    push @{ $self->{_messages} }, Koha::Object::Message->new($params);
376
    push @{ $self->{_messages} }, Koha::Object::Message->new($params);
377
}
378
379
=head3 $object->read_only();
380
381
Set the object as read_only, only getter methods will be allowed
382
383
=cut
384
385
sub read_only {
386
    my ($self) = @_;
387
388
    $self->{_read_only} = 1;
377
389
378
    return $self;
390
    return $self;
379
}
391
}
Lines 811-816 sub AUTOLOAD { Link Here
811
    # Using direct setter/getter like $item->barcode() or $item->barcode($barcode);
823
    # Using direct setter/getter like $item->barcode() or $item->barcode($barcode);
812
    if ( grep { $_ eq $method } @columns ) {
824
    if ( grep { $_ eq $method } @columns ) {
813
        if ( @_ ) {
825
        if ( @_ ) {
826
            die "Setter method $method called on read-only object"
827
                if $self->{_read_only};
814
            $self->_result()->set_column( $method, @_ );
828
            $self->_result()->set_column( $method, @_ );
815
            return $self;
829
            return $self;
816
        } else {
830
        } else {
Lines 819-824 sub AUTOLOAD { Link Here
819
        }
833
        }
820
    }
834
    }
821
835
836
    die "Cannot call method $method on a read-only object"
837
        if $self->{_read_only};
838
822
    my @known_methods = qw( is_changed id in_storage get_column discard_changes make_column_dirty );
839
    my @known_methods = qw( is_changed id in_storage get_column discard_changes make_column_dirty );
823
840
824
    Koha::Exceptions::Object::MethodNotCoveredByTests->throw(
841
    Koha::Exceptions::Object::MethodNotCoveredByTests->throw(
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +22 lines)
Lines 19-25 Link Here
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Test::More tests => 28;
22
use Test::More tests => 29;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 1171-1176 EOF Link Here
1171
    is( $letter->{content}, $expected_content );
1171
    is( $letter->{content}, $expected_content );
1172
};
1172
};
1173
1173
1174
subtest 'Execute TT process in a DB transaction' => sub {
1175
    plan tests => 2;
1176
    my $code = 'TEST_TXN';
1177
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
1178
    my $template = <<EOF;
1179
=[% branch.branchcode %]=
1180
[%~ branch.delete ~%]
1181
EOF
1182
    reset_template({ template => $template, code => $code, module => 'test' });
1183
    my $letter = GetPreparedLetter(
1184
        module      => 'test',
1185
        letter_code => $code,
1186
        tables      => {
1187
            branches => $library->branchcode,
1188
        }
1189
    );
1190
    my $branchcode = $library->branchcode;
1191
    like($letter->{content}, qr{=$branchcode=}, 'content generated with the library');
1192
    is( ref($library->get_from_storage), 'Koha::Library', 'calling ->delete on the object has not been comitted');
1193
};
1194
1174
sub reset_template {
1195
sub reset_template {
1175
    my ( $params ) = @_;
1196
    my ( $params ) = @_;
1176
    my $template   = $params->{template};
1197
    my $template   = $params->{template};
1177
- 

Return to bug 28739