Revision 96670fe8
Von Moritz Bunkus vor etwa 8 Jahren hinzugefügt
SL/Controller/RequirementSpec.pm | ||
---|---|---|
121 | 121 |
sub action_ajax_save_time_and_cost_estimate { |
122 | 122 |
my ($self) = @_; |
123 | 123 |
|
124 |
$self->requirement_spec->db->do_transaction(sub {
|
|
124 |
$self->requirement_spec->db->with_transaction(sub {
|
|
125 | 125 |
# Make Emacs happy |
126 | 126 |
1; |
127 | 127 |
foreach my $attributes (@{ $::form->{requirement_spec_items} || [] }) { |
... | ... | |
417 | 417 |
} |
418 | 418 |
|
419 | 419 |
my $db = $self->requirement_spec->db; |
420 |
if (!$db->do_transaction(sub {
|
|
420 |
if (!$db->with_transaction(sub {
|
|
421 | 421 |
if ($self->copy_source) { |
422 | 422 |
$self->requirement_spec($self->copy_source->create_copy(%{ $params })); |
423 | 423 |
} else { |
424 | 424 |
$self->requirement_spec->save(cascade => 1); |
425 | 425 |
} |
426 |
1; |
|
426 | 427 |
})) { |
427 | 428 |
$::lxdebug->message(LXDebug::WARN(), "Error: " . $db->error); |
428 | 429 |
@errors = ($::locale->text('Saving failed. Error message from the database: #1', $db->error)); |
... | ... | |
635 | 636 |
return $self->js->error(@errors)->render if @errors; |
636 | 637 |
|
637 | 638 |
my $db = $self->requirement_spec->db; |
638 |
if (!$db->do_transaction(sub {
|
|
639 |
if (!$db->with_transaction(sub {
|
|
639 | 640 |
$project->save; |
640 | 641 |
$self->requirement_spec->update_attributes(project_id => $project->id); |
641 | 642 |
|
Auch abrufbar als: Unified diff
»with_transaction« anstelle von »do_transaction« verwenden
Es sollte so selten wie möglich »do_transaction« verwndet werden, damit
man sich immer angewöhnt, »with_transaction« zu nutzen.
Hintergründe und Unterschiede zwischen den beiden Funktionen sind in der
Dokumentation von SL/DB.pm beschrieben.