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 <paul.derscheid@lmscloud.de>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-08-15 12:21:10 +02:00 committed by Katrin Fischer
parent 0f255728c5
commit 8aced236e9
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -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;