Review main Merged

86822[TASK] Return string in FormEngine `integer` parsing

Andreas Kienast CR +2 V +2 Easy +14 −3 updated 10/30/24, 08:59

Commit message

The method `FormEngineValidation.processValue()` is declared to return a
`string`, but that's not always the case: in case for `integer` fields,
a real `number` is returned.

Fixing this reveals another misbehavior: if a number field contains the
value "42" and the field is updated to contain the value "0042", its
value normalized to the string value `'42'` again. Due to the strict
type check for value updates, the value is not considered as changed,
and therefore the "human-readable" field was not updated with the
normalized (formatted) value.

This commit therefore changes two things:

* string values are now returned when parsing `integer` fields
* the user facing field is now always updated to contain a clean value

Review

  • Code review CR +2 Done
    • Andreas Kienast +2
    • Benjamin Franzke +1
    • Ayke Halder +1
  • Verified V +2 Done
    • Andreas Kienast +2
    • Benjamin Franzke +1
    • Ayke Halder +1
    • core-ci +1 CI

Issues 1

Files 3

Review log 1418

  1. Andreas Kienast uploaded patch set 1 10/29/24, 12:01

  2. core-ci voted on patch set 1 V +1 10/29/24, 12:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68780

  3. Andreas Kienast updated the commit message in patch set 2 V +1 10/29/24, 13:42

  4. core-ci voted on patch set 2 V +1 10/29/24, 13:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68788

  5. Ayke Halder commented on patch set 2 10/29/24, 14:16

    Looks good, maybe add a small test-case for `"integer"` returned as `string` in `Build/Sources/TypeScript/backend/tests/form-engine-validation-test.ts` ``` const processValueDataProvider: Array<ProcessValueData> = [ … { 'description': 'works for command integer with numeric value', 'command': 'integer', 'value': '1234', 'config': {}, 'result': '1234' } ```
  6. Andreas Kienast commented on patch set 2 10/29/24, 14:18

    Reply

    Ack, sounds reasonable.
  7. Andreas Kienast uploaded patch set 3 V +1 10/29/24, 14:19

  8. core-ci voted on patch set 3 V +1 10/29/24, 14:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68789

  9. Ayke Halder voted on patch set 3 CR +1 V +1 10/29/24, 14:34

  10. Benjamin Franzke commented on patch set 3 CR -1 10/29/24, 17:47

    Normalizing to integer is fine, but that we need to convert back to string to compare if the value has actually been changed or not. Otherwise entering "0042" when value is currently "42" will be tracked as a changed value, although the value is kept as-is.
  11. Ayke Halder commented on patch set 3 10/29/24, 19:46

    Reply

    A number-field beeing marked as "changed", even in case there was no change, is a pretty old issue. Should this be fixed for TYPo3 12? Or can this wait for the implementation of a kind of "reset to original value"-feature, which introduces comparision to the original value. E.g. right now if an editor changes a text input once and then back to the original value it is also marked as changed, which might be fixed with a "reset to original value"-feature.
  12. Andreas Kienast commented on patch set 3 10/30/24, 06:44

    Reply

    Marking a field as changed happens in `change` event handlers, which is another outstanding topic on its own. I agree the status quo sucks, but that's for another quest.
  13. Benjamin Franzke uploaded patch set 4 CR +1 V +1 10/30/24, 08:09

  14. Benjamin Franzke commented on patch set 4 10/30/24, 08:09

    Reply

    Ack
    I couldn't find a user facing bug here (the issue also mentioned code refactoring only), therefore changed to TASK here.
  15. core-ci voted on patch set 4 V +1 10/30/24, 08:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68826

  16. Ayke Halder voted on patch set 4 CR +1 V +1 10/30/24, 08:44

  17. Andreas Kienast commented on patch set 4 CR +2 V +2 10/30/24, 08:49

    Thanks, guys.
  18. Andreas Kienast merged patch set 5 10/30/24, 08:59