From: Sven Schöling Date: Wed, 15 May 2013 12:34:09 +0000 (+0200) Subject: Merge branch 'master' of github.com:kivitendo/kivitendo-erp X-Git-Tag: release-3.1.0beta1~412 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/commitdiff_plain/2b96805c82afc5fa9f7678815ef6d537dd5cfed6?hp=e855756795da07e79807b8cf1a31cfea8d253d61 Merge branch 'master' of github.com:kivitendo/kivitendo-erp --- diff --git a/SL/DB.pm b/SL/DB.pm index 90e08c582..5a22c5da5 100644 --- a/SL/DB.pm +++ b/SL/DB.pm @@ -129,7 +129,15 @@ sub _flatten_settings { sub with_transaction { my ($self, $code, @args) = @_; - return $self->in_transaction ? $code->(@args) : $self->do_transaction(sub { $code->(@args) }); + return $code->(@args) if $self->in_transaction; + if (wantarray) { + my @result; + return $self->do_transaction(sub { @result = $code->(@args) }) ? @result : (); + + } else { + my $result; + return $self->do_transaction(sub { $result = $code->(@args) }) ? $result : undef; + } } 1; @@ -162,21 +170,27 @@ configuration. =item C -Executes C<$code_ref> within a transaction, starting one if none is -currently active. This is just a shortcut for the following code: - - # Verbose code in caller (an RDBO instance): - my $worker = sub { - # do stuff with $self - }; - return $self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker); - -Now the version using C: +Executes C<$code_ref> with parameters C<@args> within a transaction, +starting one if none is currently active. Example: return $self->db->with_transaction(sub { # do stuff with $self }); +One big difference to L is the return code +handling. If a transaction is already active then C +simply returns the result of calling C<$code_ref> as-is. + +Otherwise the return value depends on the result of the underlying +transaction. If the transaction fails then C is returned in +scalar context and an empty list in list context. If the transaction +succeeds then the return value of C<$code_ref> is returned preserving +context. + +So if you want to differentiate between "transaction failed" and +"succeeded" then your C<$code_ref> should never return C +itself. + =back =head1 BUGS diff --git a/scripts/locales.pl b/scripts/locales.pl index 8105abd9a..93b34fda1 100755 --- a/scripts/locales.pl +++ b/scripts/locales.pl @@ -166,6 +166,14 @@ close($js_file); my @new_missing = grep { !$self->{texts}{$_} } sort keys %alllocales; if (@new_missing) { + if ($opt_c) { + my %existing_lc = map { (lc $_ => $_) } grep { $self->{texts}->{$_} } keys %{ $self->{texts} }; + foreach my $entry (@new_missing) { + my $other = $existing_lc{lc $entry}; + print "W: No entry for '${entry}' exists, but there is one with different case: '${other}'\n" if $other; + } + } + generate_file( file => "$locales_dir/missing", header => $MISSING_HEADER,