Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 486fe464

Von Moritz Bunkus vor fast 14 Jahren hinzugefügt

  • ID 486fe464fc69883e89ce37518473bfb688354d6f
  • Vorgänger 626ec4b4
  • Nachfolger 2da6fbfb

Admin-DB-Upgrade-Funktion nach DBUpgrade2 verschoben

Unterschiede anzeigen:

SL/DBUpgrade2.pm
329 329
sub unapplied_upgrade_scripts {
330 330
  my ($self, $dbh) = @_;
331 331

  
332
  $::lxdebug->dump(0, "self", $self);
333

  
332 334
  my @all_scripts = map { $_->{applied} = 0; $_ } $self->sort_dbupdate_controls;
333 335

  
334 336
  my $query = qq|SELECT tag FROM | . $self->{schema} . qq|schema_info|;
......
342 344
  return grep { !$_->{applied} } @all_scripts;
343 345
}
344 346

  
347
sub apply_admin_dbupgrade_scripts {
348
  my ($self, $called_from_admin) = @_;
349

  
350
  return if !$self->{auth};
351

  
352
  my $dbh               = $::auth->dbconnect;
353
  my @unapplied_scripts = $self->unapplied_upgrade_scripts($dbh);
354

  
355
  return if !@unapplied_scripts;
356

  
357
  my $db_charset           = $main::dbcharset || Common::DEFAULT_CHARSET;
358
  $self->{form}->{login} ||= 'admin';
359

  
360
  map { $_->{description} = SL::Iconv::convert($_->{charset}, $db_charset, $_->{description}) } values %{ $self->{all_controls} };
361

  
362
  $self->{form}->{title} = $::locale->text('Dataset upgrade');
363
  $self->{form}->header;
364
  print $self->{form}->parse_html_template("dbupgrade/header", { dbname => $::auth->{DB_config}->{db} });
365

  
366
  foreach my $control (@unapplied_scripts) {
367
    $::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}");
368
    print $self->{form}->parse_html_template("dbupgrade/upgrade_message2", $control);
369

  
370
    $self->process_file($dbh, "sql/$self->{dbdriver}-upgrade2-auth/$control->{file}", $control, $db_charset);
371
  }
372

  
373
  print $self->{form}->parse_html_template("dbupgrade/footer", { is_admin => $called_from_admin });
374
  ::end_of_request();
375
}
376

  
345 377
sub _check_for_loops {
346 378
  my ($form, $file_name, $controls, $tag, @path) = @_;
347 379

  
......
395 427
sub sort_dbupdate_controls {
396 428
  my $self = shift;
397 429

  
430
  $self->parse_dbupdate_controls unless $self->{all_controls};
431

  
398 432
  return sort { ($a->{depth} <=> $b->{depth}) || ($a->{priority} <=> $b->{priority}) || ($a->{tag} cmp $b->{tag}) } values %{ $self->{all_controls} };
399 433
}
400 434

  

Auch abrufbar als: Unified diff