From 8aced236e9360ea6186e0d4c79d77ecd272bdc09 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 15 Aug 2024 12:21:10 +0200 Subject: [PATCH] Bug 37429: Set default value for global variables The global variables needs to be assigned with a default value, or the value from the previous request will be used. Global variables are persistent from one request to another, in memory. This patch: * groups default value for global variables together * removes $authorised_values_sth from this list (it is not a global var) * set $changed_framework to 0 (which fix the issue) Test plan: 1. Open an existing biblio (detail.pl) 2. Click "Edit record" 3. Change the framework (no need to change any details) 4. Change the framework back to the original one (no need to save anything) 5. Go back to the biblio overview page (detail.pl) => The form is populated Signed-off-by: Paul Derscheid Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- cataloguing/addbiblio.pl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 99c20580b5..9d41a15a64 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -66,7 +66,7 @@ if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) { MARC::File::XML->default_record_format('UNIMARC'); } -our($tagslib,$authorised_values_sth,$is_a_modif,$usedTagsLib,$mandatory_z3950,$op,$changed_framework); +our ( $tagslib, $usedTagsLib, $mandatory_z3950, $is_a_modif, $op, $changed_framework ); =head1 FUNCTIONS @@ -501,7 +501,6 @@ my $biblionumber = $input->param('biblionumber'); # if biblionumber exists, it' my $parentbiblio = $input->param('parentbiblionumber'); my $breedingid = $input->param('breedingid'); my $z3950 = $input->param('z3950'); -$op = $input->param('op') // q{}; my $mode = $input->param('mode') // q{}; my $frameworkcode = $input->param('frameworkcode'); my $redirect = $input->param('redirect'); @@ -518,6 +517,14 @@ my $fa_duedatespec = $input->param('duedatespec'); my $userflags = 'edit_catalogue'; +# Set default values for global variable +$tagslib = &GetMarcStructure( 1, $frameworkcode ); +$usedTagsLib = &GetUsedMarcStructure($frameworkcode); +$mandatory_z3950 = GetMandatoryFieldZ3950($frameworkcode); +$is_a_modif = 0; +$op = $input->param('op') // q{}; +$changed_framework = 0; + if ( $op eq 'cud-change-framework' ) { $op = $input->param('original_op'); $changed_framework = 1; @@ -587,12 +594,6 @@ $template->param( breedingid => $breedingid, ); -# ++ Global -$tagslib = &GetMarcStructure( 1, $frameworkcode ); -$usedTagsLib = &GetUsedMarcStructure( $frameworkcode ); -$mandatory_z3950 = GetMandatoryFieldZ3950($frameworkcode); -# -- Global - my $record = -1; my $encoding = ""; my ( @@ -654,8 +655,6 @@ if ($parentbiblio) { } } -$is_a_modif = 0; - if ($biblionumber) { $is_a_modif = 1; my $title = C4::Context->preference('marcflavour') eq "UNIMARC" ? $record->subfield('200', 'a') : $record->title; -- 2.39.5