From 5cba820797f8cc83dfd271efb208da676da12eec Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 3 Nov 2020 16:45:33 +0100 Subject: [PATCH] Bug 26911: (bug 18936 follow-up) Remove invalid data before copying the circ rules UPDATE: changed queries to not touch * values To test: 1 - Checkout 19.11.x and reset_all 2 - Add a new patron category, itemtype, and branch to your system 3 - Create issuing rules using thise 3 values, and others 4 - Delete the new category, itemtype and branch 5 - Checkout master 6 - Restart_all 7 - updatedatabase 8 - you get errors 9 - repeat 1-5 10 - apply patch 11 - restart_all 12 - updatedatabase 13 - no errors! Signed-off-by: Nick Clemens Signed-off-by: Andrew Fuerste-Henry Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart (cherry picked from commit 31e38bc371943d1e76f49aacd1dd159a254f71e7) Signed-off-by: Lucas Gass --- installer/data/mysql/updatedatabase.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index b3a00f8d87..01bfb241cf 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -20707,6 +20707,21 @@ if( CheckVersion( $DBversion ) ) { note ); + $dbh->do(q| + DELETE i FROM issuingrules i + LEFT JOIN itemtypes it ON i.itemtype=it.itemtype + WHERE it.itemtype IS NULL AND i.itemtype!='*' + |); + $dbh->do(q| + DELETE i FROM issuingrules i + LEFT JOIN branches b ON i.branchcode=b.branchcode + WHERE b.branchcode IS NULL AND i.branchcode!='*' + |); + $dbh->do(q| + DELETE i FROM issuingrules i + LEFT JOIN categories c ON i.categorycode=c.categorycode + WHERE c.categorycode IS NULL AND i.categorycode!='*' + |); if ( column_exists( 'issuingrules', 'categorycode' ) ) { foreach my $column ( @columns ) { $dbh->do(" -- 2.39.5