Bug 25852: Improve C4::Creators::Lib reliability under plack
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 30 Jul 2020 10:00:03 +0000 (12:00 +0200)
committerVictor Grousset/tuxayo <victor@tuxayo.net>
Sun, 20 Sep 2020 11:02:09 +0000 (13:02 +0200)
commitbad82e2a3cb7d2def220bc787c1f2d58c08ec6e2
treec885ac606c72a384f07527e11fab9f033d1c7ed6
parentcab5e5fd5a919a743d4a9733d75cac643a877ef1
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 <kelly@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 0a9d3f17d9e44b5326a42d14420d30243031629d)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit e2c9fdb5bd702e358aa5b7f86e1ddf80525a4128)

Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
(cherry picked from commit 0471bd6843974b473d266ced3c50b1c95f6695ea)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
C4/Creators/Lib.pm