From 65064e1cdb981fcb0ceeba04334ecba7125f45a7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 26 Apr 2021 10:49:12 +0200 Subject: [PATCH] Bug 28207: Fix biblio_framework.frameworktext isn't in GROUP BY When a new framework is created and "Marc structure" is opened, a SQL error happened if sql_strict_mode is on. Test plan: Create a 2 new biblio frameworks Click "Marc structure" for one of them => You see the list of all frameworks with an existing structure Signed-off-by: David Nind Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Julian Maurice Signed-off-by: Jonathan Druart (cherry picked from commit f3b28bfe44bfbf1a7d0bf771bb7e3476faa2c117) Signed-off-by: Fridolin Somers --- admin/marctagstructure.pl | 22 +++++++++---------- .../prog/en/modules/admin/marctagstructure.tt | 4 ++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl index cc47c60440..634ea5e985 100755 --- a/admin/marctagstructure.pl +++ b/admin/marctagstructure.pl @@ -187,18 +187,16 @@ if ($op eq 'add_form') { ################## ITEMTYPE_CREATE ################################## # called automatically if an unexisting frameworkis selected } elsif ($op eq 'framework_create') { - $sth = $dbh->prepare("select count(*),marc_tag_structure.frameworkcode,frameworktext from marc_tag_structure,biblio_framework where biblio_framework.frameworkcode=marc_tag_structure.frameworkcode group by marc_tag_structure.frameworkcode"); - $sth->execute; - my @existingframeworkloop; - while (my ($tot,$thisframeworkcode,$frameworktext) = $sth->fetchrow) { - if ($tot>0) { - push @existingframeworkloop, { - value => $thisframeworkcode, - frameworktext => $frameworktext, - }; - } - } - $template->param( existingframeworkloop => \@existingframeworkloop ); + my $frameworks = Koha::BiblioFrameworks->search( + { + 'marc_tag_structure.frameworkcode' => { '!=' => undef } + }, + { + join => 'marc_tag_structure', + distinct => 1 + } + ); + $template->param( existing_frameworks => $frameworks ); ################## DEFAULT ################################## } else { # DEFAULT diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt index beed047e47..efbbe5b5e7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt @@ -147,8 +147,8 @@ Create framework for [% framework.frameworkcode | html %] ([% framework.frameworktext | html %]) using -- 2.39.5