Skip to content

Commit

Permalink
Issue #2298: Small bugfixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhaerter authored and svenoe committed Feb 26, 2024
1 parent 9ef5abf commit 0b20c1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions Kernel/System/DynamicField/Driver/Lens.pm
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,10 @@ sub GetFieldState {
Behavior => 'IsACLReducible',
);

my $ReferenceID = $DFParam->{ $DynamicFieldConfig->{Config}{ReferenceDFName} } ? $DFParam->{ $DynamicFieldConfig->{Config}{ReferenceDFName} }[0] : undef;

# get the current value of the referenced attribute field if an object is referenced
if ( $DFParam->{ $DynamicFieldConfig->{Config}{ReferenceDFName} } ) {
if ( $ReferenceID ) {
$AttributeFieldValue = $Self->ValueGet(
DynamicFieldConfig => $DynamicFieldConfig,

Expand Down Expand Up @@ -672,13 +674,13 @@ sub GetFieldState {
# or is currently stored for the edited ticket/ci/... (2)
my $LastSearchResults = $Kernel::OM->Get('Kernel::System::Web::FormCache')->GetFormData(
LayoutObject => $Kernel::OM->Get('Kernel::Output::HTML::Layout'),
Key => 'PossibleValues_DynamicField_' . $ReferenceDFName,
Key => 'PossibleValues_' . $ReferenceDFName,
);

my $Allowed = 0;
if ( $LastSearchResults ) {
# if a search has already been performed for this form id
$Allowed = grep { $_ eq $DFParam->{ $ReferenceDFName } } $LastSearchResults->@* ? 1 : 0;
$Allowed = ( grep { $_ eq $ReferenceID } $LastSearchResults->@* ) ? 1 : 0;
}
else {
# if no search has been performed yet, the database value for the referenced object is also valid
Expand Down
6 changes: 3 additions & 3 deletions Kernel/System/Web/FormCache.pm
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,11 @@ sub DESTROY {

SESSIONID:
for my $SessionID ( keys $Self->{CacheUpdate}->%* ) {
next SESSIONID if !IsHashRefWithContent( $Self->{CacheUpdate}{$SessionID} );
next SESSIONID if !IsHashRefWithData( $Self->{CacheUpdate}{$SessionID} );

FORMID:
for my $FormID ( keys $Self->{CacheUpdate}{$SessionID}->%* ) {
next FORMID if !IsHashRefWithContent( $Self->{CacheUpdate}{$SessionID}{$FormID} );
next FORMID if !IsHashRefWithData( $Self->{CacheUpdate}{$SessionID}{$FormID} );

# extract session data to update
my $Data = $Self->{Cache}{$SessionID}{$FormID};
Expand Down Expand Up @@ -355,7 +355,7 @@ sub DESTROY {
# store all new data
$DBObject->DoArray(
SQL => 'INSERT INTO form_cache (session_id, form_id, cache_key, cache_value, serialized, create_time) VALUES (?, ?, ?, ?, ?, current_timestamp)',
Bind => [ $SessionID, $FormID, $DataToStore{Keys}, $DataToStore{Values} ],
Bind => [ $SessionID, $FormID, $DataToStore{Keys}, $DataToStore{Values}, $DataToStore{Serialized} ],
);
}
}
Expand Down

0 comments on commit 0b20c1e

Please sign in to comment.