Skip to content
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

Recursive calls not possible #99

Open
infabo opened this issue Feb 15, 2022 · 1 comment
Open

Recursive calls not possible #99

infabo opened this issue Feb 15, 2022 · 1 comment

Comments

@infabo
Copy link
Contributor

infabo commented Feb 15, 2022

In classic Fluid with sections/partials you can do recursive calls.

Example:

<f:render section="Test" arguments="{foo: 1}"/>

<f:section name="Test">
    Hello World
    <f:if condition="{foo} === 1">
        <f:render section="Test" arguments="{foo: 0}"/>
    </f:if>
</f:section>

This would print:

Hello World Hello World

But you can't do alike with components.

Given you have a component called Button (c:atom.button) with an impossible condition:

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      xmlns:fc="http://typo3.org/ns/SMS/FluidComponents/ViewHelpers"
      data-namespace-typo3-fluid="true">
<fc:component>
    <fc:param name="link" type="Typolink"/>
    <fc:param name="label" type="string"/>
    <fc:param name="target" type="string" default="_self" optional="1"/>
    <fc:param name="style" type="string" default="primary" optional="1" description="<primary|secondary|alternate>"/>

    <fc:renderer>
       <f:link.typolink class="button button--{style}" parameter="{link}" title="{label}" target="{target}" additionalAttributes="{role: 'button'}">
           <span class="button__text">{label}</span>
       </f:link.typolink>
        <f:if condition="1 == 2">
            <c:atom.button link="{link}" label="foo"/>
        </f:if>
    </fc:renderer>
</fc:component>
</html>

Leads to:

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in /var/www/html/vendor/typo3fluid/fluid/src/Core/Parser/TemplateParser.php on line 661

In runs into a endless recursion.

@s2b
Copy link
Collaborator

s2b commented Apr 29, 2022

I left a comment in the other issue:

Hi everyone, and thank you for bringing this to our attention. That's probably a tough one to fix, but we should at least look into it if it's solvable by the extension.

One possible workaround that could work is to enable the somewhat hidden partials feature introduced with #65 and try to use partials for the recursive part. If you set the TYPO3 feature flag fluidComponents.partialsInComponents, you should be able to try this.

So yes, this is a bug, but it's probably complicated to fix. However, any help or ideas are appreciated.

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

No branches or pull requests

2 participants