From bad82e2a3cb7d2def220bc787c1f2d58c08ec6e2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 30 Jul 2020 12:00:03 +0200 Subject: [PATCH] Bug 25852: Improve C4::Creators::Lib reliability under plack This is certainly a major issue that leads to many side-effects. Under plack, the structure of the default values are not handled correctly. Package variables are used to store stuff like the "layout type". They are complex structures (arrays of hashes) and returned without being copied. When the caller (the controller script) retrieve them then modify the returned structures, it actually modifies the package's variables. One of the issue is: Create a new layout The script retrieve a structure with all "selected" flags are set to 0 It select the first one as default (BAR as selected => 1) The user creates the new layout and will selected BIBBAR (for instance) If you then edit this new layout, the script will retrieve the "label_types" and set "selected" for BIBBAR. However BAR is still selected! The UI receives 2 selected and display the first selected one that has the selected option. Test plan: 1. Create a layout type for Barcode/Biblio 2. Choose fields to print and size of font 3. Save 4. Edit existing Layout => Withtout this patch "Barcode" is the preselected option => With this patch applied, the correct "Barcode/Biblio" option is selected Signed-off-by: Kelly McElligott Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit 0a9d3f17d9e44b5326a42d14420d30243031629d) Signed-off-by: Lucas Gass (cherry picked from commit e2c9fdb5bd702e358aa5b7f86e1ddf80525a4128) Signed-off-by: Aleisha Amohia (cherry picked from commit 0471bd6843974b473d266ced3c50b1c95f6695ea) Signed-off-by: Victor Grousset/tuxayo --- C4/Creators/Lib.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/C4/Creators/Lib.pm b/C4/Creators/Lib.pm index c16a2c81a6..ea36bdf99a 100644 --- a/C4/Creators/Lib.pm +++ b/C4/Creators/Lib.pm @@ -17,8 +17,8 @@ package C4::Creators::Lib; # You should have received a copy of the GNU General Public License # along with Koha; if not, see . -use strict; -use warnings; +use Modern::Perl; +use Storable qw(dclone); use autouse 'Data::Dumper' => qw(Dumper); @@ -405,7 +405,7 @@ This function returns a reference to an array of hashes containing all barcode t =cut sub get_barcode_types { - return $barcode_types; + return dclone $barcode_types; } =head2 C4::Creators::Lib::get_label_types() @@ -417,7 +417,7 @@ This function returns a reference to an array of hashes containing all label typ =cut sub get_label_types { - return $label_types; + return dclone $label_types; } =head2 C4::Creators::Lib::get_font_types() @@ -429,7 +429,7 @@ This function returns a reference to an array of hashes containing all font type =cut sub get_font_types { - return $font_types; + return dclone $font_types; } =head2 C4::Creators::Lib::get_text_justification_types() @@ -441,7 +441,7 @@ This function returns a reference to an array of hashes containing all text just =cut sub get_text_justification_types { - return $text_justification_types; + return dclone $text_justification_types; } =head2 C4::Creators::Lib::get_unit_values() @@ -455,7 +455,7 @@ There are 72 PS points to the inch. =cut sub get_unit_values { - return $unit_values; + return dclone $unit_values; } =head2 C4::Creators::Lib::get_output_formats() @@ -467,7 +467,7 @@ This function returns a reference to an array of hashes containing all label out =cut sub get_output_formats { - return $output_formats; + return dclone $output_formats; } -- 2.39.5