Bugzilla – Attachment 102901 Details for
Bug 14698
AtomicUpdater - Keeps track of which updates have been applied to a database
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14698: AtomicUpdater - addAllAtomicUpdates
0003-Bug-14698-AtomicUpdater-addAllAtomicUpdates.patch (text/plain), 3.61 KB, created by
Emmi Takkinen
on 2020-04-14 08:26:43 UTC
(
hide
)
Description:
Bug 14698: AtomicUpdater - addAllAtomicUpdates
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2020-04-14 08:26:43 UTC
Size:
3.61 KB
patch
obsolete
>From e4a300ff6af978e48bcee7f3d420983f442f834e Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Thu, 13 Apr 2017 11:06:29 +0000 >Subject: [PATCH 3/5] Bug 14698: AtomicUpdater - addAllAtomicUpdates > >This patch adds a new method Koha::AtomicUpdater->addAllAtomicUpdates that marks >all pending atomicupdates as applied, but does not execute the database changes >in them. This is required for fresh installations to avoid applying same updates >after the installation. > >Binds this feature to web installer. > >To test: >1. prove t/db_dependent/Koha/AtomicUpdater.t >--- > Koha/AtomicUpdater.pm | 19 ++++++++++++++++ > installer/install.pl | 1 + > t/db_dependent/Koha/AtomicUpdater.t | 35 ++++++++++++++++++++++++++++- > 3 files changed, 54 insertions(+), 1 deletion(-) > >diff --git a/Koha/AtomicUpdater.pm b/Koha/AtomicUpdater.pm >index b9625c888a..4e4e040703 100644 >--- a/Koha/AtomicUpdater.pm >+++ b/Koha/AtomicUpdater.pm >@@ -130,6 +130,25 @@ sub addAtomicUpdate { > return $atomicupdate; > } > >+=head addAllAtomicUpdates >+ >+Gets all pending atomicupdates and marks them added. This is useful for installer >+where we want to set all atomicupdates marked as applied to avoid applying them >+after installation. >+ >+=cut >+ >+sub addAllAtomicUpdates { >+ my ($self) = @_; >+ >+ my $atomicUpdates = $self->getPendingAtomicUpdates(); >+ foreach my $key (keys %$atomicUpdates) { >+ $self->addAtomicUpdate($atomicUpdates->{$key}->unblessed); >+ } >+ >+ return $atomicUpdates; >+} >+ > sub removeAtomicUpdate { > my ($self, $issueId) = @_; > print "Deleting atomicupdate '$issueId'\n" if $self->{verbose} > 2; >diff --git a/installer/install.pl b/installer/install.pl >index 5bd3806872..811fa381a7 100755 >--- a/installer/install.pl >+++ b/installer/install.pl >@@ -364,6 +364,7 @@ elsif ( $step && $step == 3 ) { > "error" => $error, > "$op" => 1, > ); >+ Koha::AtomicUpdater->new->addAllAtomicUpdates(); > } > elsif ( $op && $op eq 'updatestructure' ) { > # >diff --git a/t/db_dependent/Koha/AtomicUpdater.t b/t/db_dependent/Koha/AtomicUpdater.t >index 14abf95971..f877d16deb 100644 >--- a/t/db_dependent/Koha/AtomicUpdater.t >+++ b/t/db_dependent/Koha/AtomicUpdater.t >@@ -30,7 +30,7 @@ use Koha::AtomicUpdater; > > use t::lib::TestBuilder; > >-plan tests => 8; >+plan tests => 9; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -271,6 +271,39 @@ subtest "Apply single atomicupdate from file" => sub { > > }; > >+subtest 'Mark all atomicupdates as installed (for fresh installs), but do not execute them' => sub { >+ >+ plan tests => 3; >+ >+ my $test_file1 = create_file({ >+ filepath => 'atomicupdate/', >+ filename => 'Bug_00001-First-update.pl', >+ content => '$ENV{ATOMICUPDATE_TESTS_3}++;', >+ >+ }); >+ >+ my $test_file2 = create_file({ >+ filepath => 'atomicupdate/', >+ filename => 'Bug_00002-Second-update.pl', >+ content => '$ENV{ATOMICUPDATE_TESTS_3}++;', >+ }); >+ >+ my $atomicUpdater = Koha::AtomicUpdater->new({ >+ scriptDir => $test_file1->dirname(), >+ }); >+ >+ $atomicUpdater->addAllAtomicUpdates; >+ my $atomicUpdate = $atomicUpdater->find('Bug-00001'); >+ my $atomicUpdate2 = $atomicUpdater->find('Bug-00002'); >+ >+ is($atomicUpdate->filename, "Bug_00001-First-update.pl", "Bug_00001-First-update.pl added to DB"); >+ is($atomicUpdate2->filename, "Bug_00002-Second-update.pl", "Bug_00002-Second-update.pl added to DB"); >+ is($ENV{ATOMICUPDATE_TESTS_3}, undef, "However, updates were not executed."); >+ >+ $test_file1->remove; >+ $test_file2->remove; >+}; >+ > $test_file->remove; > $schema->storage->txn_rollback; > >-- >2.17.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14698
:
42112
|
42113
|
42385
|
42386
|
42395
|
42398
|
42426
|
42521
|
42523
|
62141
|
64404
|
102899
|
102900
| 102901 |
102902
|
102903