From 6a82ff4b8907f17fb17af3201ab6e96320a995bf Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 4 Apr 2017 14:17:15 +0200 Subject: [PATCH] Bug 18376 - authority framework creation fails under Plack With plack, when creating a new authority framework from another, you get the error : Can't call method "prepare" on an undefined value at (...)/src/admin/auth_tag_structure.pl line 267. Looks like plack does not like when the var $dbh from the script is called inside a sub. This patch adds a local var $dbh inside sub duplicate_auth_framework(), like in sub StringSearch(). Also correctes a redefine of my $sth. Test plan: - Go to Administration > Authority types - Create a new type - On this new type click on Actions > MARC Structure - Select another type and click OK => You must get a table filled with the tag structure Check with and without plack You may not be able to reproduce the error with plack. Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- admin/auth_tag_structure.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/admin/auth_tag_structure.pl b/admin/auth_tag_structure.pl index fbe69de873..0832d14cab 100755 --- a/admin/auth_tag_structure.pl +++ b/admin/auth_tag_structure.pl @@ -160,10 +160,10 @@ if ($op eq 'add_form') { # called by delete_confirm, used to effectively confirm deletion of data in DB } elsif ($op eq 'delete_confirmed') { unless (C4::Context->config('demo') eq 1) { - my $sth = $dbh->prepare("delete from auth_tag_structure where tagfield=? and authtypecode=?"); - $sth->execute($searchfield,$authtypecode); - my $sth = $dbh->prepare("delete from auth_subfield_structure where tagfield=? and authtypecode=?"); - $sth->execute($searchfield,$authtypecode); + my $sth_tag = $dbh->prepare("delete from auth_tag_structure where tagfield=? and authtypecode=?"); + $sth_tag->execute($searchfield,$authtypecode); + my $sth_sub = $dbh->prepare("delete from auth_subfield_structure where tagfield=? and authtypecode=?"); + $sth_sub->execute($searchfield,$authtypecode); } my $tagfield = $input->param('tagfield'); print $input->redirect("/cgi-bin/koha/admin/auth_tag_structure.pl?searchfield=$tagfield&authtypecode=$authtypecode"); @@ -248,6 +248,7 @@ sub StringSearch { sub duplicate_auth_framework { my ($newauthtype,$oldauthtype) = @_; # warn "TO $newauthtype FROM $oldauthtype"; + my $dbh = C4::Context->dbh; my $sth = $dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from auth_tag_structure where authtypecode=?"); $sth->execute($oldauthtype); my $sth_insert = $dbh->prepare("insert into auth_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, authtypecode) values (?,?,?,?,?,?,?)"); -- 2.39.5