Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5494f687

Von Sven Schöling vor etwa 13 Jahren hinzugefügt

  • ID 5494f687372570c9d1c5eb5c6aad73767e50820a
  • Vorgänger a064deaf
  • Nachfolger 3b9a5301

$::cgi entfernt.

Verfahren:
- Für alle Vorkommen von "my $cgi = $::cgi;":
ersetzt durch my $cgi = $::request->{cgi}->new({}) ersetzt

- Wenn in einer Datei alle my $cgi rausgefallen sind auch use CGI entfernt.

- Initialisierung von $::cgi in scripts und Dispatcher entfernt und in dei
Initialisierung von $::request eingebaut.

- cgi aus der Liste der kanonischen globals genommen.

Zu CGI:
- CGI::func und CGI->func sind beides valide Werte, sind aber intern buggy wie
Hölle. CGI:: erzeugt ein Dummyobjekt mit CGI->new, und klobbert damit
cookies. CGI-> ist noch schlimmer und ruft ${CGI}->{.cookies} auf.
- CGI->new({}) ist schneller als CGI->new(''), deshalb habe ich diese version genommen.
Auf meinem Rechner schafft die erste Version etwa 32k/s, die zweite 28k/s.
- CGI kompiliert benötigte Funktionen beim ersten Aufruf über AUTOLOAD.
- cookie benötigen ein $cgi Objekt.

Unterschiede anzeigen:

SL/Auth.pm
511 511

  
512 512
  my $self = shift;
513 513

  
514
  my $cgi            =  $main::cgi;
515
  $cgi             ||=  CGI->new('');
516

  
517
  $session_id        =  $cgi->cookie($self->get_session_cookie_name());
514
  $session_id        =  $::request->{cgi}->cookie($self->get_session_cookie_name());
518 515
  $session_id        =~ s|[^0-9a-f]||g;
519 516

  
520 517
  $self->{SESSION}   = { };
SL/Controller/Base.pm
30 30
  my $self = shift;
31 31
  my $url  = $self->url_for(@_);
32 32

  
33
  print $::cgi->redirect($url);
33
  print $::request->{cgi}->redirect($url);
34 34
}
35 35

  
36 36
sub render {
SL/Controller/DebugMenu.pm
9 9
sub action_reload {
10 10
  my ($self, %params) = @_;
11 11

  
12
  print $::cgi->redirect('controller.pl?action=FrameHeader/header');
12
  print $::request->{cgi}->redirect('controller.pl?action=FrameHeader/header');
13 13
  exit;
14 14
}
15 15

  
......
17 17
  my ($self, %params) = @_;
18 18

  
19 19
  $::lxdebug->level_by_name($::form->{level}, !$::lxdebug->level_by_name($::form->{level}));
20
  print $::cgi->redirect('controller.pl?action=FrameHeader/header');
20
  print $::request->{cgi}->redirect('controller.pl?action=FrameHeader/header');
21 21
  return;
22 22
}
23 23

  
SL/Dispatcher.pm
168 168

  
169 169
  $self->unrequire_bin_mozilla;
170 170

  
171
  $::cgi           = CGI->new('');
172 171
  $::locale        = Locale->new($::lx_office_conf{system}->{language});
173 172
  $::form          = Form->new;
174 173
  $::instance_conf = SL::InstanceConfiguration->new;
175
  $::request       = { };
174
  $::request       = { cgi => CGI->new({}) };
176 175

  
177 176
  my $session_result = $::auth->restore_session;
178 177
  $::auth->create_or_refresh_session;
......
240 239
  } or do {
241 240
    if ($EVAL_ERROR ne END_OF_REQUEST) {
242 241
      print STDERR $EVAL_ERROR;
243
      $::form->{label_error} = $::cgi->pre($EVAL_ERROR);
242
      $::form->{label_error} = $::request->{cgi}->pre($EVAL_ERROR);
244 243
      eval { show_error('generic/error') };
245 244
    }
246 245
  };
......
311 310

  
312 311
    1;
313 312
  } or do {
314
    $::form->{label_error} = $::cgi->pre($EVAL_ERROR);
313
    $::form->{label_error} = $::request->{cgi}->pre($EVAL_ERROR);
315 314
    show_error('generic/error');
316 315
  };
317 316

  
......
328 327

  
329 328
    1;
330 329
  } or do {
331
    $::form->{label_error} = $::cgi->pre($EVAL_ERROR);
330
    $::form->{label_error} = $::request->{cgi}->pre($EVAL_ERROR);
332 331
    show_error('generic/error');
333 332
  };
334 333

  
SL/Form.pm
464 464
  my $self = shift;
465 465

  
466 466
  if (@_) {
467
    map({ print($main::cgi->hidden("-name" => $_, "-default" => $self->{$_}) . "\n"); } @_);
467
    map({ print($::request->{cgi}->hidden("-name" => $_, "-default" => $self->{$_}) . "\n"); } @_);
468 468
  } else {
469 469
    for (sort keys %$self) {
470 470
      next if (($_ eq "header") || (ref($self->{$_}) ne ""));
471
      print($main::cgi->hidden("-name" => $_, "-default" => $self->{$_}) . "\n");
471
      print($::request->{cgi}->hidden("-name" => $_, "-default" => $self->{$_}) . "\n");
472 472
    }
473 473
  }
474 474
  $main::lxdebug->leave_sub();
......
624 624
  my $self     = shift;
625 625
  my %params   = @_;
626 626

  
627
  my $cgi      = $main::cgi;
628
  $cgi       ||= CGI->new('');
627
  my $cgi      = $::request->{cgi};
629 628

  
630 629
  my $session_cookie;
631 630
  if (defined $main::auth) {
......
762 761
  my ($self) = @_;
763 762

  
764 763
  my $db_charset = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
765
  my $cgi        = $main::cgi || CGI->new('');
766
  my $output     = $cgi->header('-charset' => $db_charset);
764
  my $output     = $::request->{cgi}->header('-charset' => $db_charset);
767 765

  
768 766
  $main::lxdebug->leave_sub();
769 767

  
......
780 778
  die "Headers already sent" if $self->{header};
781 779
  $self->{header} = 1;
782 780

  
783
  my $cgi = $main::cgi || CGI->new('');
784
  return $cgi->redirect($new_uri);
781
  return $::request->{cgi}->redirect($new_uri);
785 782
}
786 783

  
787 784
sub set_standard_title {
bin/mozilla/admin.pl
33 33
#======================================================================
34 34

  
35 35
use DBI;
36
use CGI;
37 36
use Encode;
38 37
use English qw(-no_match_vars);
39 38
use Fcntl;
......
68 67
  $::lxdebug->enter_sub;
69 68
  my $session_result = shift;
70 69

  
71
  $cgi    = $::cgi;
72 70
  $form   = $::form;
73 71
  $locale = $::locale;
74 72
  $auth   = $::auth;
bin/mozilla/ap.pl
195 195
  my $form     = $main::form;
196 196
  my %myconfig = %main::myconfig;
197 197
  my $locale   = $main::locale;
198
  my $cgi      = $main::cgi;
198
  my $cgi      = $::request->{cgi};
199 199

  
200 200
  $main::auth->assert('general_ledger');
201 201

  
......
836 836
  my $form     = $main::form;
837 837
  my %myconfig = %main::myconfig;
838 838
  my $locale   = $main::locale;
839
  my $cgi      = $main::cgi;
839
  my $cgi      = $::request->{cgi};
840 840

  
841 841
  $main::auth->assert('general_ledger');
842 842

  
bin/mozilla/ar.pl
215 215
  my $form     = $main::form;
216 216
  my %myconfig = %main::myconfig;
217 217
  my $locale   = $main::locale;
218
  my $cgi      = $main::cgi;
218
  my $cgi      = $::request->{cgi};
219 219

  
220 220
  my ($title, $readonly, $exchangerate, $rows);
221 221
  my ($taxincluded, $notes, $department, $customer, $employee, $amount, $project);
......
879 879
  my $form     = $main::form;
880 880
  my %myconfig = %main::myconfig;
881 881
  my $locale   = $main::locale;
882
  my $cgi      = $main::cgi;
882
  my $cgi      = $::request->{cgi};
883 883

  
884 884
  my ($transdate, $closedto);
885 885

  
......
1332 1332
  my $form     = $main::form;
1333 1333
  my %myconfig = %main::myconfig;
1334 1334
  my $locale   = $main::locale;
1335
  my $cgi      = $main::cgi;
1335
  my $cgi      = $::request->{cgi};
1336 1336

  
1337 1337
  my ($customer, $department);
1338 1338
  my ($jsscript, $button1, $button2, $onload);
bin/mozilla/dn.pl
316 316
  my $form     = $main::form;
317 317
  my %myconfig = %main::myconfig;
318 318
  my $locale   = $main::locale;
319
  my $cgi      = $main::cgi;
319
  my $cgi      = $::request->{cgi};
320 320

  
321 321
  $main::auth->assert('dunning_edit');
322 322

  
bin/mozilla/do.pl
454 454
  my $form     = $main::form;
455 455
  my %myconfig = %main::myconfig;
456 456
  my $locale   = $main::locale;
457
  my $cgi      = $main::cgi;
457
  my $cgi      = $::request->{cgi};
458 458

  
459 459
  ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) = split(/--/, $form->{ $form->{vc} });
460 460

  
bin/mozilla/fu.pl
231 231
  my $form     = $main::form;
232 232
  my %myconfig = %main::myconfig;
233 233
  my $locale   = $main::locale;
234
  my $cgi      = $main::cgi;
234
  my $cgi      = $::request->{cgi};
235 235

  
236 236
  my @report_params = qw(created_for subject body reference follow_up_date_from follow_up_date_to itime_from itime_to due_only all_users done not_done);
237 237

  
bin/mozilla/gl.pl
218 218
  my $form     = $main::form;
219 219
  my %myconfig = %main::myconfig;
220 220
  my $locale   = $main::locale;
221
  my $cgi      = $main::cgi;
221
  my $cgi      = $::request->{cgi};
222 222

  
223 223
  $form->{title} = $locale->text('Journal');
224 224

  
......
507 507

  
508 508
  my @columns = qw(
509 509
    gldate         transdate        id             reference      description
510
    notes          source           debit          debit_accno   
510
    notes          source           debit          debit_accno
511 511
    credit         credit_accno     debit_tax      debit_tax_accno
512 512
    credit_tax     credit_tax_accno projectnumbers balance employee
513 513
  );
......
861 861

  
862 862
  my $form     = $main::form;
863 863
  my %myconfig = %main::myconfig;
864
  my $cgi      = $main::cgi;
864
  my $cgi      = $::request->{cgi};
865 865

  
866 866
  $form->{debit_1}     = 0 if !$form->{"debit_1"};
867 867
  $form->{totaldebit}  = 0;
......
1347 1347
  my $form     = $main::form;
1348 1348
  my %myconfig = %main::myconfig;
1349 1349
  my $locale   = $main::locale;
1350
  my $cgi      = $main::cgi;
1350
  my $cgi      = $::request->{cgi};
1351 1351

  
1352 1352
  my $follow_ups_block;
1353 1353
  if ($form->{id}) {
bin/mozilla/io.pl
113 113
  my $form     = $main::form;
114 114
  my %myconfig = %main::myconfig;
115 115
  my $locale   = $main::locale;
116
  my $cgi      = $main::cgi;
116
  my $cgi      = $::request->{cgi};
117 117

  
118 118
  my $numrows = shift;
119 119

  
......
415 415

  
416 416
  my $form     = $main::form;
417 417
  my $locale   = $main::locale;
418
  my $cgi      = $main::cgi;
418
  my $cgi      = $::request->{cgi};
419 419

  
420 420
  _check_io_auth();
421 421

  
bin/mozilla/ir.pl
262 262
  my $form     = $main::form;
263 263
  my %myconfig = %main::myconfig;
264 264
  my $locale   = $main::locale;
265
  my $cgi      = $main::cgi;
265
  my $cgi      = $::request->{cgi};
266 266

  
267 267
  $main::auth->assert('vendor_invoice_edit');
268 268

  
bin/mozilla/is.pl
285 285
  my $form     = $main::form;
286 286
  my %myconfig = %main::myconfig;
287 287
  my $locale   = $main::locale;
288
  my $cgi      = $main::cgi;
288
  my $cgi      = $::request->{cgi};
289 289

  
290 290
  $main::auth->assert('invoice_edit');
291 291

  
......
335 335
  my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
336 336
  $form->{currency}            = $form->{defaultcurrency} unless $form->{currency};
337 337
  $form->{show_exchangerate}   = $form->{currency} ne $form->{defaultcurrency};
338
  $TMPL_VAR{currencies}        = NTI($::cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
338
  $TMPL_VAR{currencies}        = NTI($::request->{cgi}->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
339 339
                                                      '-values' => \@values, '-labels' => \%labels)) if scalar @values;
340 340
  push @custom_hiddens, "forex";
341 341
  push @custom_hiddens, "exchangerate" if $form->{forex};
bin/mozilla/login.pl
45 45
  $::lxdebug->enter_sub;
46 46
  my $session_result = shift;
47 47

  
48
  $cgi    = $::cgi;
49 48
  $form   = $::form;
50 49
  $auth   = $::auth;
51 50

  
bin/mozilla/oe.pl
298 298
  my $form     = $main::form;
299 299
  my %myconfig = %main::myconfig;
300 300
  my $locale   = $main::locale;
301
  my $cgi      = $main::cgi;
301
  my $cgi      = $::request->{cgi};
302 302

  
303 303
  check_oe_access();
304 304

  
......
744 744
  my $form     = $main::form;
745 745
  my %myconfig = %main::myconfig;
746 746
  my $locale   = $main::locale;
747
  my $cgi      = $main::cgi;
747
  my $cgi      = $::request->{cgi};
748 748

  
749 749
  check_oe_access();
750 750

  
bin/mozilla/rp.pl
176 176
  }
177 177

  
178 178
  my $projectnumber =
179
    NTI($main::cgi->popup_menu('-name' => "project_id",
179
    NTI($::request->{cgi}->popup_menu('-name' => "project_id",
180 180
                               '-values' => \@project_values,
181 181
                               '-labels' => \%project_labels));
182 182

  
......
1663 1663
  my $form     = $main::form;
1664 1664
  my %myconfig = %main::myconfig;
1665 1665
  my $locale   = $main::locale;
1666
  my $cgi      = $main::cgi;
1666
  my $cgi      = $::request->{cgi};
1667 1667

  
1668 1668
  my $report = SL::ReportGenerator->new(\%myconfig, $form);
1669 1669

  
bin/mozilla/sepa.pl
176 176

  
177 177
  my $form   = $main::form;
178 178
  my $locale = $main::locale;
179
  my $cgi    = $main::cgi;
179
  my $cgi    = $::request->{cgi};
180 180
  my $vc     = $form->{vc} eq 'customer' ? 'customer' : 'vendor';
181 181

  
182 182
  $form->{title}     = $vc eq 'customer' ? $::locale->text('List of bank collections') : $locale->text('List of bank transfers');
......
443 443
  my $form     =  $main::form;
444 444
  my $myconfig = \%main::myconfig;
445 445
  my $locale   =  $main::locale;
446
  my $cgi      =  $main::cgi;
446
  my $cgi      =  $::request->{cgi};
447 447
  my $vc       = $form->{vc} eq 'customer' ? 'customer' : 'vendor';
448 448

  
449 449
  if (!$myconfig->{company}) {
bin/mozilla/vk.pl
54 54
  my $form     = $main::form;
55 55
  my %myconfig = %main::myconfig;
56 56
  my $locale   = $main::locale;
57
  my $cgi      = $main::cgi;
58 57

  
59 58
  my ($customer, $department);
60 59

  
......
100 99
    # Nichts führt, daher diese Zwischenlösung
101 100

  
102 101
    &check_name('customer', no_select => 1);
103
  
102

  
104 103
    # $form->{customer_id} wurde schon von check_name gesetzt
105 104
    $form->{customername} = $form->{customer};
106 105
  };
......
312 311

  
313 312
    if ( $subtotals2{qty} != 0 ) {
314 313
      $subtotals2{sellprice} = $subtotals2{sellprice_total} / $subtotals2{qty};
315
      $subtotals2{lastcost} = $subtotals2{lastcost_total} / $subtotals2{qty}; 
314
      $subtotals2{lastcost} = $subtotals2{lastcost_total} / $subtotals2{qty};
316 315
    } else {
317 316
      $subtotals2{sellprice} = 0;
318 317
      $subtotals2{lastcost} = 0;
scripts/console
62 62

  
63 63
  $::lxdebug       = LXDebug->new(file => $debug_file);
64 64
  $::locale        = Locale->new($::lx_office_conf{system}->{language});
65
  $::cgi           = CGI->new qw();
66 65
  $::form          = Form->new;
67 66
  $::auth          = SL::Auth->new;
68 67
  $::instance_conf = SL::InstanceConfiguration->new;
69
  $::request       = { };
68
  $::request       = { cgi => CGI->new({}) };
70 69

  
71 70
  die 'cannot reach auth db'               unless $::auth->session_tables_present;
72 71

  
scripts/rose_auto_create_model.pl
31 31
my %package_names = SL::DB::Helper::Mappings->get_package_names;
32 32

  
33 33
our $form;
34
our $cgi;
35 34
our $auth;
36 35
our %lx_office_conf;
37 36

  
......
59 58
  $::lxdebug      = LXDebug->new();
60 59
  $::locale       = Locale->new("de");
61 60
  $::form         = new Form;
62
  $::cgi          = new CGI('');
63 61
  $::auth         = SL::Auth->new();
64 62
  $::user         = User->new($login);
65 63
  %::myconfig     = $auth->read_user($login);
66
  $::request      = { };
64
  $::request      = { cgi => CGI->new({}) };
67 65
  $form->{script} = 'rose_meta_data.pl';
68 66
  $form->{login}  = $login;
69 67

  
scripts/task_server.pl
40 40

  
41 41
  $::lxdebug = LXDebug->new;
42 42
  $::locale  = Locale->new($::lx_office_conf{system}->{language});
43
  $::cgi     = CGI->new qw();
44 43
  $::form    = Form->new;
45 44
  $::auth    = SL::Auth->new;
46
  $::request = { };
45
  $::request = { cgi => CGI->new({}) };
47 46

  
48 47
  die 'cannot reach auth db'               unless $::auth->session_tables_present;
49 48

  
t/structure/globals.t
7 7
my (@globals, $testcount);
8 8

  
9 9
BEGIN {
10
  @globals = qw(lxdebug auth myconfig form cgi lx_office_conf locale dispatcher instance_conf request);
10
  @globals = qw(lxdebug auth myconfig form lx_office_conf locale dispatcher instance_conf request);
11 11
  $testcount = scalar(@Support::Files::testitems);
12 12
}
13 13

  

Auch abrufbar als: Unified diff