Skip to content

fix(destinationfield): prevent stale value leak across form answers#1202

Open
DaviidMM wants to merge 1 commit into
pluginsGLPI:mainfrom
DaviidMM:fix/1201-stale-value-leak-destinationfield
Open

fix(destinationfield): prevent stale value leak across form answers#1202
DaviidMM wants to merge 1 commit into
pluginsGLPI:mainfrom
DaviidMM:fix/1201-stale-value-leak-destinationfield

Conversation

@DaviidMM
Copy link
Copy Markdown

@DaviidMM DaviidMM commented May 22, 2026

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.

Description

  • Fixes Form Helpdesk: custom field value overwritten by stale $value from previous QuestionTypeItemDropdown answer #1201

  • In PluginFieldsDestinationField::applyConfiguratedValueToInputUsingAnswers(),
    $value is assigned only inside the QuestionTypeItemDropdown branch and is
    never reset between iterations of the foreach ($answers as $answer) loop.
    On a later iteration targeting a non-dropdown field (number, text,
    textarea, richtext, url, date, datetime), the expression
    $value ?? $answer->getRawAnswer() returned the stale $value from the
    previous iteration, silently overwriting the user's typed value with the
    items_id of the earlier item-dropdown answer.

  • $value has no meaning outside the QuestionTypeItemDropdown branch (the
    glpi_item / dropdown branches read items_id directly from the current
    answer), so the fall-through else must always read from the current answer:

    - $input[$field_name] = $value ?? $answer->getRawAnswer();
    + $input[$field_name] = $answer->getRawAnswer();
  • Single-line change in inc/destinationfield.class.php. No behavior change
    for QuestionTypeItemDropdown, glpi_item or dropdown target field types.

  • Reproduction and root cause analysis are detailed in Form Helpdesk: custom field value overwritten by stale $value from previous QuestionTypeItemDropdown answer #1201.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Form Helpdesk: custom field value overwritten by stale $value from previous QuestionTypeItemDropdown answer

1 participant