Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision af412f0d

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID af412f0dd1d839d9afb9d55bb3feff0670dca3da
  • Vorgänger 66c08b64
  • Nachfolger d3160c04

Das Einspielen von Client-DB-Upgrades gefixt

Unterschiede anzeigen:

SL/User.pm
115 115

  
116 116
  my $dbupdater = SL::DBUpgrade2->new(form => $form)->parse_dbupdate_controls;
117 117

  
118
  $form->{$_} = $::auth->client->{$_} for qw(dbname dbhost dbport dbuser dbpasswd);
119
  $form->{$_} = $myconfig{$_}         for qw(dateformat);
120

  
121
  dbconnect_vars($form, $form->{dbname});
122

  
123 118
  my $update_available = $dbupdater->update_available($dbversion) || $dbupdater->update2_available($dbh);
124 119
  $dbh->disconnect;
125 120

  
126 121
  return 0 if !$update_available;
122

  
123
  $form->{$_} = $::auth->client->{$_} for qw(dbname dbhost dbport dbuser dbpasswd);
124
  $form->{$_} = $myconfig{$_}         for qw(datestyle);
125

  
127 126
  $form->{"title"} = $main::locale->text("Dataset upgrade");
128 127
  $form->header(no_layout => $form->{no_layout});
129 128
  print $form->parse_html_template("dbupgrade/header");
130 129

  
131
  $form->{dbupdate} = "db" . $form->{dbname};
130
  $form->{dbupdate} = "db" . $::auth->client->{dbname};
132 131

  
133 132
  if ($form->{"show_dbupdate_warning"}) {
134 133
    print $form->parse_html_template("dbupgrade/warning");
......
143 142
  $SIG{QUIT} = 'IGNORE';
144 143

  
145 144
  $self->dbupdate($form);
146
  $self->dbupdate2($form, $dbupdater);
145
  $self->dbupdate2(form => $form, updater => $dbupdater, database => $::auth->client->{dbname});
147 146
  SL::DBUpgrade2->new(form => $::form, auth => 1)->apply_admin_dbupgrade_scripts(0);
148 147

  
149 148
  SL::System::InstallationLock->unlock;
......
534 533
sub dbupdate2 {
535 534
  $main::lxdebug->enter_sub();
536 535

  
537
  my ($self, $form, $dbupdater) = @_;
536
  my ($self, %params) = @_;
538 537

  
539
  my $rc         = -2;
540
  my $db_charset = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
538
  my $form            = $params{form};
539
  my $dbupdater       = $params{updater};
540
  my $db              = $params{database};
541
  my $rc              = -2;
542
  my $db_charset      = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
541 543

  
542 544
  map { $_->{description} = SL::Iconv::convert($_->{charset}, $db_charset, $_->{description}) } values %{ $dbupdater->{all_controls} };
543 545

  
544
  foreach my $db (split / /, $form->{dbupdate}) {
545
    next unless $form->{$db};
546
  &dbconnect_vars($form, $db);
546 547

  
547
    # strip db from dataset
548
    $db =~ s/^db//;
549
    &dbconnect_vars($form, $db);
548
  my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) or $form->dberror;
550 549

  
551
    my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options) or $form->dberror;
550
  $dbh->do($form->{dboptions}) if ($form->{dboptions});
552 551

  
553
    $dbh->do($form->{dboptions}) if ($form->{dboptions});
554

  
555
    $self->create_schema_info_table($form, $dbh);
556

  
557
    my @upgradescripts = $dbupdater->unapplied_upgrade_scripts($dbh);
558

  
559
    $dbh->disconnect and next if !@upgradescripts;
552
  $self->create_schema_info_table($form, $dbh);
560 553

  
561
    foreach my $control (@upgradescripts) {
562
      # apply upgrade
563
      $main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}");
564
      print $form->parse_html_template("dbupgrade/upgrade_message2", $control);
554
  my @upgradescripts = $dbupdater->unapplied_upgrade_scripts($dbh);
565 555

  
566
      $dbupdater->process_file($dbh, "sql/Pg-upgrade2/$control->{file}", $control, $db_charset);
567
    }
556
  $dbh->disconnect and next if !@upgradescripts;
568 557

  
569
    $rc = 0;
570
    $dbh->disconnect;
558
  foreach my $control (@upgradescripts) {
559
    # apply upgrade
560
    $main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}");
561
    print $form->parse_html_template("dbupgrade/upgrade_message2", $control);
571 562

  
563
    $dbupdater->process_file($dbh, "sql/Pg-upgrade2/$control->{file}", $control, $db_charset);
572 564
  }
573 565

  
566
  $rc = 0;
567
  $dbh->disconnect;
568

  
574 569
  $main::lxdebug->leave_sub();
575 570

  
576 571
  return $rc;

Auch abrufbar als: Unified diff