---- Reported by koha@brinkerhoff.org 2008-12-23 11:50:19 ---- When I try to delete the 'Franklin' library from the sample data included with Koha 3.00.00 the web interface claims the library entry was deleted: Library deleted However the page refreshes and the library is still present. [Tue Dec 23 14:48:31 2008] [error] [client 216.107.221.XXX] [Tue Dec 23 14:48:31 2008] branches.pl: DBD::mysql::st execute failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha/borrowers`, CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)) at /usr/share/koha/lib/C4/Branch.pm line 473., referer: http://XXXXXXXXXX:8080/cgi-bin/koha/admin/branches.pl?branchcode=FRL&branchname=Franklin&op=delete ---- Additional Comments From koha@brinkerhoff.org 2008-12-23 11:53:23 ---- delete from borrowers where branchcode != "LIBRARYCODEIWANTTOKEEP"; allowed me to delete the other libraries as expected -- however branches.pl should probably check to see if there are any constraints that will be violated on delete -- or atleast requery to see if the library still exists after delete and give the user an error. ---- Additional Comments From koha@brinkerhoff.org 2008-12-23 12:03:04 ---- diff --git a/admin/branches.pl b/admin/branches.pl index fecc030..c01aa59 100755 --- a/admin/branches.pl +++ b/admin/branches.pl @@ -123,6 +123,11 @@ elsif ( $op eq 'delete' ) { $sth->execute( $branchcode, $branchcode ); my ($total) = $sth->fetchrow_array; $sth->finish; + + my $sth = $dbh->prepare("select count(*) from borrowers where branchcode=?"); + $sth->execute($branchcode); + my ($total) += $sth->fetchrow_array; + $sth->finish; my $message; --- Bug imported by chris@bigballofwax.co.nz 2010-05-21 00:57 UTC --- This bug was previously known as _bug_ 2882 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=2882 Unknown operating system Linux - Other. Setting to default OS "All". Actual time not defined. Setting to 0.0 The original reporter of this bug does not have an account here. Reassigning to the person who moved it here: chris@bigballofwax.co.nz. Previous reporter was koha@brinkerhoff.org.
This patch does not seem to be present in 3.0.x - reopening and I will try to apply it before the 3.0.7 release.
Fixed in master.