From 9ba1a4fb10b039425edc10a4d6b1be61ad376f81 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 16 Oct 2014 09:58:24 +0200 Subject: [PATCH] Bug 13068: Counterpatch follow-up for controlling workflow Content-Type: text/plain; charset=utf-8 The workflow for dev updates can be altered with pref DevUpdateControl: [1] DevUpdateControl= PROD for production machines: Do not execute RunRemainingDevUpdates, so only official db revs. This is the default. [2] DevUpdateControl= RESET: Reinstall dev updates after an official db rev. [3] DevUpdateControl= ALWAYS: Run the dev updates at each upgrade. [4] DevUpdateControl=TRACK: Only install new dev updates. It does not reset the local pref listing all recently applied dev updates. ONLY use this if you know what you are doing! Note: If the pref does not exist or is empty, we fall back to PROD (safest). If the pref differs from PROD, ALWAYS or TRACK, it falls back to RESET. Test plan: [1] Add a few lines calling ExecDBRev to updatedatabase with corresponding files in atomicupdate like (insert the correct version!!): ExecDBRev( $aupd, '13068', 'My test', '13068.pl', '3.17.00.028'); Do not forget to update kohaversion.pl accordingly. Add some other files in atomicupdate as dev updates. [2] Repeat for the various modes of DevUpdateControl (see above): Reset the database version. You could edit Version in local preferences. Optionally clear/delete the _LocalAtomicUpdates pref. Run updatestructure and check which db revs and dev updates are run or skipped. Run it again and check which dev updates are run or skipped. Signed-off-by: Marcel de Rooy --- installer/data/mysql/updatedatabase.pl | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 6df583d..50bff60 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -50,6 +50,7 @@ use constant ATOMICUPD_PREF => '_LocalAtomicUpdates'; my $debug = 0; my $aupd = { #hash for atomic updates location => C4::Context->config('intranetdir')."/installer/data/mysql/atomicupdate", + mode => C4::Context->preference('DevUpdateControl') || 'PROD', remember => C4::Context->preference(ATOMICUPD_PREF)//'', skipfiles => { 'Bug-4246-Talking-Tech-itiva-phone-notifications.pl' => 1, @@ -8898,7 +8899,8 @@ sub RunRemainingAtomicUpdates { if( exists $atomicupd->{skipfiles}->{$upd} ) { next; # Skip official db revision } - if( $atomicupd->{remember} =~ /(^|;)$upd;/ ) { + if( $atomicupd->{mode} ne 'ALWAYS' && + $atomicupd->{remember} =~ /(^|;)$upd;/ ) { #Skip files that have recently been applied #Note that an official db rev erases this list print "Skipping $upd as recently applied dev update\n"; @@ -8956,7 +8958,7 @@ sub ExecDBRev { print "Dev upgrade $file done\n"; _atomic_memory( $atomicupd, $file ) if $rv; } else { - _atomic_memory( $atomicupd ); #Official db rev clears the atomic pref + _atomic_memory( $atomicupd ); #Official dbrev may clear atomic pref SetVersion($version); print "Upgrade to $version done (Bug $bugno - $descr)\n"; } @@ -8964,6 +8966,10 @@ sub ExecDBRev { sub _atomic_memory { my ( $atomicupd, $upd ) = @_; + + return if $atomicupd->{mode} eq 'ALWAYS'; # ignores the pref + return if !$upd && $atomicupd->{mode} eq 'TRACK'; # no reset + $atomicupd->{remember}= $upd? $atomicupd->{remember}."$upd;": ''; C4::Context->set_preference( ATOMICUPD_PREF, $atomicupd->{remember} ); } @@ -9077,5 +9083,5 @@ sub CheckVersion { } } -RunRemainingAtomicUpdates( $aupd ); +RunRemainingAtomicUpdates( $aupd ) if $aupd->{mode} ne 'PROD'; exit; -- 1.7.7.6