Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 38a2e789

Von Moritz Bunkus vor fast 14 Jahren hinzugefügt

  • ID 38a2e7894debd7bc5787e74129f8f6f4e74ed2dc
  • Vorgänger dbcd72ed
  • Nachfolger 9b0c7269

Funktionen update_available, update2_available nach DBUpgrade2.pm verschoben

Unterschiede anzeigen:

SL/DBUpgrade2.pm
1 1
package SL::DBUpgrade2;
2 2

  
3 3
use IO::File;
4
use List::MoreUtils qw(any);
4 5

  
5 6
use SL::Common;
6 7
use SL::Iconv;
......
117 118

  
118 119
  $::lxdebug->leave_sub();
119 120

  
120
  return \%all_controls;
121
  return $self;
121 122
}
122 123

  
123 124
sub process_query {
......
290 291
  }
291 292
}
292 293

  
294
sub update_available {
295
  my ($self, $cur_version) = @_;
296

  
297
  local *SQLDIR;
298

  
299
  my $dbdriver = $self->{dbdriver};
300
  opendir SQLDIR, "sql/${dbdriver}-upgrade" || error("", "sql/${dbdriver}-upgrade: $!");
301
  my @upgradescripts = grep /${dbdriver}-upgrade-\Q$cur_version\E.*\.(sql|pl)$/, readdir SQLDIR;
302
  closedir SQLDIR;
303

  
304
  return ($#upgradescripts > -1);
305
}
306

  
307
sub update2_available {
308
  $::lxdebug->enter_sub();
309

  
310
  my ($self, $dbh) = @_;
311

  
312
  map { $_->{applied} = 0; } values %{ $self->{all_controls} };
313

  
314
  my $sth = $dbh->prepare(qq|SELECT tag FROM | . $self->{schema} . qq|schema_info|);
315
  if ($sth->execute) {
316
    while (my ($tag) = $sth->fetchrow_array) {
317
      $self->{all_controls}->{$tag}->{applied} = 1 if defined $self->{all_controls}->{$tag};
318
    }
319
  }
320
  $sth->finish();
321

  
322
  my $needs_update = any { !$_->{applied} } values %{ $self->{all_controls} };
323

  
324
  $::lxdebug->leave_sub();
325

  
326
  return $needs_update;
327
}
328

  
293 329
sub _check_for_loops {
294 330
  my ($form, $file_name, $controls, $tag, @path) = @_;
295 331

  

Auch abrufbar als: Unified diff