From a4ec768e3787ff3ee426949c0f03188dd4d15e82 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 16 May 2018 15:39:04 +0200 Subject: [PATCH] Bug 20773: (bug 20724 follow-up) Add a simple db revision MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We should correct bad data too. This is a trivial, pragmatic approach. Instead of doing a complex calculation with holidays etc. (as was done on 12063), we just add MaxPickupDelay or 7 days to today probably resulting in a little bonus time. Only for waiting holds. When the ReservesNeedReturns pref was not Automatic, there should be no changes. == Test plan == 1. git checkout c585f1149770ec401f188e061211501897cec0bf~1 This the commit before bug 20724's patches. We need that to be able to generate "corrupted data" 2. Set ReservesNeedReturns to "Automatically" 3. Place a hold on a specific item 4. The hold should have an *empty* expiration date record page → Hold → "Expiration" column 5. Apply this patch 6. Run updatedatabase.pl 7. Refresh the page 8. The hold should have an expiration date (not empty) 9. Celebrate! 🎉🎊🥳 Signed-off-by: Marcel de Rooy Signed-off-by: Victor Grousset Signed-off-by: Chris Cormack Bug 20773: (followup) Remove MySQLism Signed-off-by: Victor Grousset Signed-off-by: Chris Cormack Signed-off-by: Nick Clemens --- installer/data/mysql/atomicupdate/bug_20773.perl | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_20773.perl diff --git a/installer/data/mysql/atomicupdate/bug_20773.perl b/installer/data/mysql/atomicupdate/bug_20773.perl new file mode 100644 index 0000000000..d93d30433f --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_20773.perl @@ -0,0 +1,11 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + my $dtf = Koha::Database->new->schema->storage->datetime_parser; + my $days = C4::Context->preference('MaxPickupDelay') || 7; + my $date = DateTime->now()->add( days => $days ); + my $sql = q|UPDATE reserves SET expirationdate = ? WHERE expirationdate IS NULL AND waitingdate IS NOT NULL|; + $dbh->do( $sql, undef, $dtf->format_datetime($date) ); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 20724 - expirationdate filled for waiting holds)\n"; +} -- 2.20.1