if ($ref2->{trans_id} != $trans->[0]->{trans_id}) {
$form->error("Unbalanced ledger! old trans_id " . $trans->[0]->{trans_id} . " new trans_id " . $ref2->{trans_id} . " count $count");
- exit 1;
+ ::end_of_request();
}
push @{ $trans }, $ref2;
use Rose::DB::Object;
use File::Basename;
+# Trailing new line is added so that Perl will not add the line
+# number 'die' was called in.
+use constant END_OF_REQUEST => "END-OF-REQUEST\n";
+
sub pre_request_checks {
show_error('login/auth_db_unreachable') unless $::auth->session_tables_present;
$::auth->expire_sessions;
print $::form->parse_html_template($template);
$::lxdebug->leave_sub;
- exit;
+ ::end_of_request();
}
sub pre_startup_setup {
1;
} or do {
- $::form->{label_error} = $::cgi->pre($EVAL_ERROR);
- show_error('generic/error');
+ if ($EVAL_ERROR ne END_OF_REQUEST) {
+ $::form->{label_error} = $::cgi->pre($EVAL_ERROR);
+ eval { show_error('generic/error') };
+ }
};
# cleanup
}
}
+package main;
+
+use strict;
+
+sub end_of_request {
+ die SL::Dispatcher->END_OF_REQUEST;
+}
+
1;
$self->show_generic_error($msg);
} else {
-
- die "Error: $msg\n";
+ print STDERR "Error: $msg\n";
+ ::end_of_request();
}
$main::lxdebug->leave_sub();
my $info = "Developer information: templates/webpages/${file}.html is newer than the translation file locale/${language}/all.\n" .
"Please re-run 'locales.pl' in 'locale/${language}'.";
print(qq|<pre>$info</pre>|);
- die($info);
+ ::end_of_request();
}
$file = "templates/webpages/${file}.html";
my $info = "Web page template '${file}' not found.\n" .
"Please re-run 'locales.pl' in 'locale/${language}'.";
print(qq|<pre>$info</pre>|);
- die($info);
+ ::end_of_request();
}
if ($self->{"DEBUG"}) {
$self->header();
print $self->parse_html_template("generic/error", $add_params);
+ print STDERR "Error: $error\n";
+
$main::lxdebug->leave_sub();
- die("Error: $error\n");
+ ::end_of_request();
}
sub show_generic_information {
$main::lxdebug->leave_sub();
- die("Information: $text\n");
+ ::end_of_request();
}
# write Trigger JavaScript-Code ($qty = quantity of Triggers)
if (!$self->{callback}) {
$self->info($msg);
- exit;
+ ::end_of_request();
}
# my ($script, $argv) = split(/\?/, $self->{callback}, 2);
</body>
|;
- exit;
+ ::end_of_request();
} else {
if ($form->{"show_dbupdate_warning"}) {
print $form->parse_html_template("dbupgrade/warning");
- exit(0);
+ ::end_of_request();
}
# update the tables
# Process a Perl script which updates the database.
# If the script returns 1 then the update was successful.
# Return code "2" means "needs more interaction; remove
-# users/nologin and exit".
+# users/nologin and end current request".
# All other return codes are fatal errors.
sub process_perl_script {
$main::lxdebug->enter_sub();
print $form->parse_html_template("dbupgrade/error",
{ "file" => $filename,
"error" => $@ });
- exit(0);
+ ::end_of_request();
} elsif (1 != $result) {
unlink("users/nologin") if (2 == $result);
- exit(0);
+ ::end_of_request();
}
if (ref($version_or_control) eq "HASH") {
$form->header();
print $form->parse_html_template('admin/check_auth_database', \%params);
- exit 0;
+ ::end_of_request();
}
if (!$main::auth->check_tables()) {
$form->header();
print $form->parse_html_template('admin/check_auth_tables', \%params);
- exit 0;
+ ::end_of_request();
}
if (-f $main::memberfile) {
print $form->parse_html_template('admin/user_migration', { 'memberfile' => $main::memberfile,
'backupdir' => $backupdir });
- exit 0
+ ::end_of_request();
}
}
$form->header();
print $form->parse_html_template('am/confirm_delete_warehouse');
- exit 0;
+ ::end_of_request();
}
if (AM->delete_warehouse(\%myconfig, $form)) {
my ($vendor) = split /--/, $form->{vendor};
if ($form->{oldvendor} ne "$vendor--$form->{vendor_id}") {
&update;
- exit;
+ ::end_of_request();
}
my ($debitaccno, $debittaxkey) = split /--/, $form->{AP_amountselected};
my ($taxkey, $NULL) = split /--/, $form->{taxchartselected};
my ($customer) = split /--/, $form->{customer};
if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
update();
- exit;
+ ::end_of_request();
}
$form->{AR}{receivables} = $form->{ARselected};
$form->error($locale->text("More than one #1 found matching, please be more specific.", $locale->text(ucfirst $name)));
} else {
&select_name($name);
- exit;
+ ::end_of_request();
}
}
# check form->{project_list} how many there are
$form->{rownumber} = $i;
&select_project($i ? undef : 1, $nextsub);
- exit;
+ ::end_of_request();
}
if ($rows == 1) {
print $locale->text('done');
$form->redirect($locale->text('Marked entries printed!'));
}
- exit;
+ ::end_of_request();
}
}
if ($form->{currency} ne $form->{oldcurrency}) {
&update;
- exit;
+ ::end_of_request();
}
$form->error($locale->text('Zero amount posting!')) if !$form->parse_amount(\%myconfig, $form->{amount});
}
# /saving the history
&edit;
- exit;
+
$main::lxdebug->leave_sub();
+ ::end_of_request();
}
sub delete {
if ($rows > 1) {
select_item();
- exit;
+ ::end_of_request();
} else {
# if the name changed get new values
if (check_name($form->{vc})) {
update();
- exit;
+ ::end_of_request();
}
$form->{id} = 0 if $form->{saveasnew};
if(!$form->{print_and_save}) {
set_headings("edit");
update();
- exit;
+ ::end_of_request();
}
$main::lxdebug->leave_sub();
}
# /saving the history
$form->info($locale->text('Delivery Order deleted!'));
- exit();
+ ::end_of_request();
}
$form->error($locale->text('Cannot delete delivery order!'));
update();
$main::lxdebug->leave_sub();
- exit 0;
+ ::end_of_request();
}
}
update();
$main::lxdebug->leave_sub();
- exit 0;
+ ::end_of_request();
}
}
if ($form->{POPUP_MODE}) {
$form->header();
print $form->parse_html_template('fu/close_window');
- exit 0;
+ ::end_of_request();
}
$form->{SAVED_MESSAGE} = $locale->text('Follow-Up saved.');
if ($form->{POPUP_MODE}) {
$form->header();
print $form->parse_html_template('fu/close_window');
- exit 0;
+ ::end_of_request();
}
$form->redirect() if ($form->{callback});
if ($form->{POPUP_MODE}) {
$form->header();
print $form->parse_html_template('fu/close_window');
- exit 0;
+ ::end_of_request();
}
$form->redirect() if ($form->{callback});
if ($rows > 1) {
$form->{makemodel_rows}--;
&select_item;
- exit;
+ ::end_of_request();
} else {
map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
qw(partnumber description unit partsgroup);
</body>
</html>
|);
- exit(0);
+
+ ::end_of_request();
}
1;
# if we have a display_form
if ($form->{display_form}) {
call_sub($form->{"display_form"});
- exit;
+ ::end_of_request();
}
Common::webdav_folder($form) if ($main::webdav);
# $form->{print_and_post} = 0;
#
# &print_form($old_form);
- # exit;
+ # ::end_of_request();
# }
#
# $form->{action} = "";
# check if items are valid
if ($form->{rowcount} == 1) {
&update;
- exit;
+ ::end_of_request();
}
for my $i (1 .. $form->{rowcount} - 1) {
&save();
$form->{formname} = $formname;
&edit();
- exit;
+ ::end_of_request();
}
&print_form($old_form);
$form->save_history($form->dbconnect(\%myconfig));
}
# /saving the history
- exit;
+ ::end_of_request();
}
}
}
call_sub($display_form);
- exit;
+ ::end_of_request();
}
my $msg =
}
if ($form->{printing}) {
call_sub($display_form);
- exit;
+ ::end_of_request();
}
$main::lxdebug->leave_sub();
if ($rows > 1) {
&select_item;
- exit;
+ ::end_of_request();
} else {
# if the vendor changed get new values
if (&check_name('vendor')) {
&update;
- exit;
+ ::end_of_request();
}
if ($myconfig{mandatory_departments} && !$form->{department_id}) {
if ($rows > 1) {
&select_item;
- exit;
+ ::end_of_request();
} else {
# if oldcustomer ne customer redo form
if (&check_name('customer')) {
&update;
- exit;
+ ::end_of_request();
}
if ($myconfig{mandatory_departments} && !$form->{department_id}) {
. $locale->text(
"No licenses were found that match the search criteria.")
. qq|</body></html>|);
- exit(0);
+ ::end_of_request();
}
print(
if (SL::Auth::SESSION_EXPIRED == $session_result) {
$form->{error_message} = $locale->text('The session is invalid or has expired.');
login_screen();
- exit;
+ ::end_of_request();
}
my $action = $form->{action};
if (!$action && $auth->{SESSION}->{login}) {
unless ($form->{login}) {
login_screen($locale->text('You did not enter a name!'));
- exit;
+ ::end_of_request();
}
my $user = new User $form->{login};
# if we get an error back, bale out
my $result;
if (($result = $user->login($form)) <= -1) {
- exit if $result == -2;
+ ::end_of_request() if $result == -2;
login_screen($locale->text('Incorrect username or password!'));
- exit;
+ ::end_of_request();
}
my %style_to_script_map = ( 'v3' => 'v3',
# $form->parse_html_template('login/auth_db_unreachable');
# $form->parse_html_template('login/authentication_pl_missing');
- exit;
+ ::end_of_request();
}
1;
if ($rows > 1) {
&select_item;
- exit;
+ ::end_of_request();
} else {
$form->{payment_id} = $payment_id;
}
&update;
- exit;
+ ::end_of_request();
}
$form->{id} = 0 if $form->{saveasnew};
$form->{payment_id} = $payment_id;
}
&update;
- exit;
+ ::end_of_request();
}
$form->{id} = 0 if $form->{saveasnew};
if(!$form->{print_and_save}) {
delete @{$form}{ary_diff([keys %{ $form }], [qw(login stylesheet id script type cursor_fokus)])};
edit();
- exit;
+ ::end_of_request();
}
$main::lxdebug->leave_sub();
}
}
# /saving the history
$form->info($msg);
- exit();
+ ::end_of_request();
}
$form->error($err);
if (&check_name($form->{vc})) {
$form->{payment_id} = $payment_id if $form->{payment_id} eq "";
&update;
- exit;
+ ::end_of_request();
}
$form->{cp_id} *= 1;
if (!$exchangerate) {
&backorder_exchangerate($orddate, $buysell);
- exit;
+ ::end_of_request();
}
}
$main::lxdebug->leave_sub();
- exit 0;
+ ::end_of_request();
}
sub purchase_order {
} else {
$form->header;
USTVA::error( $locale->text('Wrong Period' ));
- exit(0);
+ ::end_of_request();
}
my $tax_office = first { $_->{name} eq $form->{elsterland} } @{ $ustva->{tax_office_information} };
} elsif ( $form->{format} eq '' ){ # No format error.
$form->header;
USTVA::error( $locale->text('Application Error. No Format given' ) . "!");
- exit(0);
+ ::end_of_request();
} else { # All other Formats are wrong
$form->header;
USTVA::error( $locale->text('Application Error. Wrong Format') . ": " . $form->{format} );
- exit(0);
+ ::end_of_request();
}
if (!scalar @transfers) {
$form->show_generic_information($locale->text('Nothing has been selected for transfer.'));
- exit 0;
+ ::end_of_request();
}
WH->transfer(@transfers);
if (!scalar @transfers) {
$form->show_generic_information($locale->text('Nothing has been selected for removal.'));
- exit 0;
+ ::end_of_request();
}
WH->transfer(@transfers);
4. TODO
-4.1. Fehlermeldungen, die per $form->error() ausgegeben werden, werden momentan doppelt angezeigt.
-
-4.2. "exit" sollte unter FastCGI nicht verwendet werden, startet ja den Prozess neu. Nur die Abhandlung des Requests sollte beendet werden.