Review main Abandoned

86660[BUGFIX] Respect already declared return type in `FormEngineValidation`

Ayke Halder CR 0 V 0 Easy +18 −3 updated 10/29/24, 14:10

Commit message

With this change the already declared return type becomes valid.

Before `FormEngineValidation.processValue('integer', …)` returned a
value of type `number` - with the actually return type declared as
`string`.

The return-type mismatch introduced a 'hidden feature':
An `if`-condition always evaluated to `true` under certain
circumstances by strictly comparing values with different types.
Whereas type-hinting assumed they were of the same type.

```
// string !== number
if (field.value !== newValue) {…}
```

The code-logic of this 'hidden feature' is explicitly implemented now.

This is an outcast of another change that introduces a complete
type-declaration for `FormEngineValidation`.
For easy backporting this here becomes its own change.

Review

  • Code review CR 0
  • Verified V 0

Issues 2

Files 3

Review log 89

  1. Ayke Halder uploaded patch set 1 10/19/24, 20:26

  2. Ayke Halder rebased onto patch set 2 10/20/24, 12:57

  3. core-ci voted on patch set 2 V +1 10/20/24, 13:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68259

  4. Andreas Kienast commented on patch set 2 CR -1 10/25/24, 10:36

    form-engine-validation.ts:192

    Why do we need this? The `integer` case now safely returns a string, matching the type in `.value`. Also, relying on having `integer` at the end of the eval list looks very error-prone to me. This is something that deserves an acceptance test.
  5. Ayke Halder commented on patch set 2 10/25/24, 20:47

    form-engine-validation.ts:192 Reply

    If we want to backport, then this "silly-looking check" is needed to make sure, that the UI-behaviour does not change. Checking that the string contains `integer` **at the end** is exactly what makes the UI-behaviour to be the same as before. ---- An acceptance test might look like this: * Use a form input-element `format=integer` (e.g. styleguide TCA demo -> elements basic -> tab: number -> field: number_2) * Put in value `2`, then unfocus. * Check that the value in the visible field is `2`. * Put in value `2.5`, then unfocus. * Check that the value in the visible field is `2` again and not `2.5`. The hidden input that goes to the database has always the value `2`, for both the visible values `2` and `2.5`. If we drop this "silly-looking check", the visible field is not updated, as the hidden value did not change. And thereby the visible value would still show `2.5` - whereas `2` from the hidden field is stored to the databse. ---- In case there will be no backport of this change: Drop the "silly-looking check" and go directly for this implementation: https://review.typo3.org/c/Packages/TYPO3.CMS/+/86662/
  6. Andreas Kienast commented on patch set 2 10/28/24, 07:26

    form-engine-validation.ts:192 Reply

    Thanks for working on the FormEngine topic. However: I'd prefer to get necessary refactoring done first before adding new features.
  7. Andreas Kienast commented on patch set 2 10/29/24, 11:38

    form-engine-validation.ts:192 Reply

    I've took a deeper look into the validation stuff now: If I understand your major pain point correctly: you write "0042" into a number field, the value is kept as is (if we use the modified code in line 458), but after saving it becomes "42" again. I noticed that, if I keep using "0042" and then edit the field again and prepend additional numbers, the leading "00" gets removed again, which apparently is another bug in the data normalization.
  8. Andreas Kienast commented on patch set 2 10/29/24, 12:02

    form-engine-validation.ts:192 Reply Unresolved

    I've pushed an alternative approach: https://review.typo3.org/c/Packages/TYPO3.CMS/+/86822
  9. Ayke Halder abandoned the change 10/29/24, 14:10