76693[BUGFIX] Form variant condition patch
Commit message
Review
-
Code review CR 0
-
Verified V 0
Issues 1
Files 3
Review log 2027
Show 2 earlier messages
-
core-ci voted on patch set 1 V -1 11/18/22, 11:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33916
-
core-ci voted on patch set 2 V -1 11/18/22, 11:33 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33917
-
Jan Helke commented on patch set 2 11/18/22, 11:43
-
David Nax uploaded patch set 3
V -111/22/22, 11:52 -
Oliver Klee commented on patch set 3 11/22/22, 11:59
RenderableVariant.php:113This annotation is not necessary as we already have the native return type.RenderableVariant.php:115ReplyWe'll need to do an instanceof check before calling the method that is only available in the particular class.RenderableVariantInterface.php:35This annotation is not necessary as we already have the native return type. -
core-ci voted on patch set 3 V +1 11/22/22, 12:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34072
-
Oliver Klee commented on patch set 3 11/22/22, 12:11
David, there is a merge conflict. Could you please rebase, resolve the conflict, and repush? -
David Nax uploaded patch set 4
V +111/22/22, 13:04 -
core-ci voted on patch set 4 V +1 11/22/22, 13:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34075
-
Oliver Klee commented on patch set 4 11/22/22, 14:50
RenderableVariant.php:113ReplyDoneRenderableVariantInterface.php:35ReplyDone -
David Nax commented on patch set 4 12/01/22, 11:59
RenderableVariant.php:113ReplyDoneRenderableVariant.php:115ReplyI added the method to the interface.RenderableVariantInterface.php:35ReplyDone -
Jan Helke voted on patch set 4 V +1 CR +1 12/01/22, 12:00
-
Oliver Klee wrote 12/01/22, 12:17
Removed cc Oliver Klee. -
Benni Mack updated the commit message in patch set 5
CR +1V +105/03/23, 09:25 -
core-ci voted on patch set 5 V -1 05/03/23, 11:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41411
-
Oliver Hader rebased onto patch set 6
V -105/03/23, 12:39 -
core-ci voted on patch set 6 V +1 05/03/23, 13:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41528
-
Sebastian Klein commented on patch set 6 06/19/23, 13:22
FormRuntime.php:468Using `str_starts_with` will not match variants for multiselect fields, where the condition checks for an array value (`"value" in formValues["multicheckbox-1"]`). -
Benni Mack rebased onto patch set 7
V +107/06/23, 17:36 -
core-ci voted on patch set 7 V +1 07/06/23, 17:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43786
-
Christian Spoo commented on patch set 7 CR -1 08/09/23, 12:15
tbh, I am not quite happy with the idea of parsing all registered form field conditions in order to find out where the various form variants are going to differ. IMHO the core problem is that the formValues variable passed to the ExpressionLanguage context has no possibility of checking whether a certain form value is actually present or not, rendering dynamic forms useless on PHP >= 8. Personally I'd prefer introducing a proper formValues API (an object instead of a simple array) that allows the integrator to do sth. like a has() call in the condition to check for the presence of a form value. Think of it like https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php (of course in its frozen form FrozenParameterBag). Such a - let's call it FormValues - class should implement ArrayAccess and Traversable in order to provide backwards compatibility. That way we could even equip 11.5 with a compatible solution in order to make the mechanism work. FormState is marked @internal so there would be no BC break in terms of public APIs through the new result type of FormState::getFormValues(). What do you think? Remember that EXT:form is currently broken in 11.5 running on PHP 8 and we should definitely deal with that. -
David Nax commented on patch set 7 09/01/23, 14:55
Reply
At first glance your idea sounds convincing to me. But honestly, the FormRuntime is so huge that I don't entirely get all the interrelations, so I would not dare to make bigger changes. I wonder why `$this->processVariants()` is already called twice (in `FormRuntime->initialize()` and `...->render()`), so before the FormState and its values are filled. I just tested with 12.4 and PHP 8, here the Bug is still a problem.FormRuntime.php:468ReplyI am not sure if I understood your point. The basic problem is that `processVariants()` is also called on `FormRuntime->initialize()` (for whatever reasons), when the form state not yet has any values. In this case, the statement `formValues["multicheckbox-1"]` would result in an error because the form values do not (yet) have the key 'multicheckbox-1'. The aim of the patch is to prevent this. What the patch does not cover is to evaluate the form values, this is happening later in the `conditionMatches()` call. I guess this is what you refer to. In our case, we just want to know if the variant starts with "formValues" and if the corresponding values are (still) empty. -
Christian Spoo commented on patch set 7 09/01/23, 15:31
Reply
If that's the conclusion I'm actually a bit frightened. The form sysext is rather new (compared with TSFE and friends ;-) ) and if it was generally accepted that it's too complex to be improved further, we are basically talking about a bigger problem than failing form conditions. Or did I misunderstand something? Would you mind if I gave my idea a try? To be honest I am not familiar with TYPO3's usual process of managing different approaches to the same problem in terms of two concurrent patch sets. But I'd like to try to implement this FormValues class and I'd love to hear some feedback if I can get it to work.FormRuntime.php:468ReplyThe point is that your logic parses the condition string and assumes that all problematic ones start with "formValues". Conditions like the one shown by Sebastian won't pass your if-condition but will nevertheless trigger the bug behaviour. See, it won't even be better if we'd replace str_starts_with by str_contains to mitigate that. It's the fragility of such simple approaches that was also the reason for my previous comment to the overall solution. Hence my suggestion of adding logic to the formValues object itself. -
David Nax commented on patch set 7 09/01/23, 20:38
Christian takes it from here. I added Lolli as CC since he might also have an opinion on this.Reply Unresolved
Please, proceed with your idea. I am happy to give up my approach in favor of a more general and sustainable solution. For the record, I closed Sebastians comment https://review.typo3.org/c/Packages/TYPO3.CMS/+/76693/comment/779e45dc_2261d67e/ assuming that you will cover also this problem.FormRuntime.php:468ReplyMaybe I got Sebastian's example wrong. I admit that my solution is too narrow. I propose to resolve this discussion in favor of https://review.typo3.org/c/Packages/TYPO3.CMS/+/76693/comments/f40427d0_b07ada04 so that we don't have too much loose ends. -
Georg Ringer abandoned the change 06/27/24, 15:39
abandoned, just use traverse
RenderableVariant.php:115