Skip to content

[BUGFIX] Differentiate between null and unset then/else condition branches #1051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 17, 2025

Conversation

s2b
Copy link
Contributor

@s2b s2b commented Apr 16, 2025

With Fluid 4.1 (in 96099a6) it became possible to
use f:if and other condition-based ViewHelpers without then or else, which
would return the result of the condition as boolean. However, the current
implementation of this feature didn't consider the difference between a ViewHelper
without any then or else and one with then that returns null. These two
examples would both return the boolean:

{f:if(condition: myCondition, then: myUndefinedVariable)}
{f:if(condition: myCondition)}

With this change, the two examples are treated differently. Instead of checking
the arguments of the ViewHelper (which are already merged with the defined
default values), the ViewHelperNode is used to find out if the argument has
actually been specified. This applies both for uncached rendering and compilation,
which is used for cached templates.

Since the implementation in AbstractConditionViewHelper became more and more
convoluted, both the rendering and the compilation step have been refactored.
Also, more test cases are added, which make sure that the issues of the current
implementation are still addressed with the refactored code.

Resolves: #1049

@s2b
Copy link
Contributor Author

s2b commented Apr 16, 2025

Apart from composer integrity, TYPO3 Core CI is green: https://git.typo3.org/typo3/CI/cms/-/pipelines/77859

@s2b s2b force-pushed the bugfix/ifVerdictReturn branch 3 times, most recently from 67d3e9d to a8ad079 Compare April 17, 2025 09:25
@s2b s2b force-pushed the bugfix/ifVerdictReturn branch from a8ad079 to 54e92b6 Compare April 17, 2025 14:41
@s2b s2b merged commit 32f0656 into main Apr 17, 2025
8 checks passed
@s2b s2b deleted the bugfix/ifVerdictReturn branch April 17, 2025 14:53
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.

IfViewhelper returns "true" instead of empty string if condition result is null
3 participants