View | Details | Raw Unified | Return to bug 14698
Collapse All | Expand All

(-)a/Koha/AtomicUpdater.pm (+19 lines)
Lines 130-135 sub addAtomicUpdate { Link Here
130
    return $atomicupdate;
130
    return $atomicupdate;
131
}
131
}
132
132
133
=head addAllAtomicUpdates
134
135
Gets all pending atomicupdates and marks them added. This is useful for installer
136
where we want to set all atomicupdates marked as applied to avoid applying them
137
after installation.
138
139
=cut
140
141
sub addAllAtomicUpdates {
142
    my ($self) = @_;
143
144
    my $atomicUpdates = $self->getPendingAtomicUpdates();
145
    foreach my $key (keys %$atomicUpdates) {
146
        $self->addAtomicUpdate($atomicUpdates->{$key}->unblessed);
147
    }
148
149
    return $atomicUpdates;
150
}
151
133
sub removeAtomicUpdate {
152
sub removeAtomicUpdate {
134
    my ($self, $issueId) = @_;
153
    my ($self, $issueId) = @_;
135
    print "Deleting atomicupdate '$issueId'\n" if $self->{verbose} > 2;
154
    print "Deleting atomicupdate '$issueId'\n" if $self->{verbose} > 2;
(-)a/installer/install.pl (+1 lines)
Lines 364-369 elsif ( $step && $step == 3 ) { Link Here
364
            "error" => $error,
364
            "error" => $error,
365
            "$op"   => 1,
365
            "$op"   => 1,
366
        );
366
        );
367
        Koha::AtomicUpdater->new->addAllAtomicUpdates();
367
    }
368
    }
368
    elsif ( $op && $op eq 'updatestructure' ) {
369
    elsif ( $op && $op eq 'updatestructure' ) {
369
        #
370
        #
(-)a/t/db_dependent/Koha/AtomicUpdater.t (-2 / +34 lines)
Lines 30-36 use Koha::AtomicUpdater; Link Here
30
30
31
use t::lib::TestBuilder;
31
use t::lib::TestBuilder;
32
32
33
plan tests => 8;
33
plan tests => 9;
34
34
35
my $schema  = Koha::Database->new->schema;
35
my $schema  = Koha::Database->new->schema;
36
$schema->storage->txn_begin;
36
$schema->storage->txn_begin;
Lines 271-276 subtest "Apply single atomicupdate from file" => sub { Link Here
271
271
272
};
272
};
273
273
274
subtest 'Mark all atomicupdates as installed (for fresh installs), but do not execute them' => sub {
275
276
   plan tests => 3;
277
278
   my $test_file1 = create_file({
279
      filepath => 'atomicupdate/',
280
      filename => 'Bug_00001-First-update.pl',
281
      content  => '$ENV{ATOMICUPDATE_TESTS_3}++;',
282
283
   });
284
285
   my $test_file2 = create_file({
286
      filepath => 'atomicupdate/',
287
      filename => 'Bug_00002-Second-update.pl',
288
      content  => '$ENV{ATOMICUPDATE_TESTS_3}++;',
289
   });
290
291
   my $atomicUpdater = Koha::AtomicUpdater->new({
292
      scriptDir => $test_file1->dirname(),
293
   });
294
295
   $atomicUpdater->addAllAtomicUpdates;
296
   my $atomicUpdate = $atomicUpdater->find('Bug-00001');
297
   my $atomicUpdate2 = $atomicUpdater->find('Bug-00002');
298
299
   is($atomicUpdate->filename, "Bug_00001-First-update.pl", "Bug_00001-First-update.pl added to DB");
300
   is($atomicUpdate2->filename, "Bug_00002-Second-update.pl", "Bug_00002-Second-update.pl added to DB");
301
   is($ENV{ATOMICUPDATE_TESTS_3}, undef, "However, updates were not executed.");
302
303
   $test_file1->remove;
304
   $test_file2->remove;
305
};
306
274
$test_file->remove;
307
$test_file->remove;
275
$schema->storage->txn_rollback;
308
$schema->storage->txn_rollback;
276
309
277
- 

Return to bug 14698