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

[TwigComponent] Undefined var $name in ComponentExtension ? #1115

Closed
smnandre opened this issue Sep 14, 2023 · 7 comments · Fixed by #1117
Closed

[TwigComponent] Undefined var $name in ComponentExtension ? #1115

smnandre opened this issue Sep 14, 2023 · 7 comments · Fixed by #1117

Comments

@smnandre
Copy link
Collaborator

In TwigComponent/src/Twig/ComponentExtension, there is this method

    public function finishEmbeddedComponentRender(): void
    {
        try {
            $this->container->get(ComponentRenderer::class)->finishEmbeddedComponentRender();
        } catch (\Throwable $e) {
            $this->throwRuntimeError($name, $e);
        }
    }

I fear this won't work as $name is not defined... or am I missing something ?

@kbond
Copy link
Member

kbond commented Sep 14, 2023

Looks like a bug to me. Either we need to change the catch logic or or pass the name to the method. I don't know the context of this logic off the top of my head. @sneakyvv?

@smnandre
Copy link
Collaborator Author

Same thing @kbond :)

I'd code that, but i have no idea how to test that correctly, with LiveComponents, ...

    $compiler->write('$this->extensions[')
        ->string(ComponentExtension::class)
        ->raw(']->finishEmbeddedComponentRender(')
        ->string($this->getAttribute('component'))
        ->string(')')
        ->raw(";\n")
    ;

@kbond
Copy link
Member

kbond commented Sep 14, 2023

Did you hit this try...catch and get an \ArgumentCountError thrown?

@smnandre
Copy link
Collaborator Author

Hmm where ? Around this one or in throwRuntimeError ? Sorry i'm not sure how to handle that.. :|

@kbond
Copy link
Member

kbond commented Sep 14, 2023

I'm just wondering how you stumbled upon this bug. Just by looking at code or did an app actually run this and throw an exception.

(I'm trying to gauge how important it is to require the name here - can we just remove the try catch and let the caught exception be thrown as normal?)

@smnandre
Copy link
Collaborator Author

Reading code, and PhpStorm alerted me with some red wavy line :)

@smnandre
Copy link
Collaborator Author

I have to leave, i can try your solution in a couple of hours

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 a pull request may close this issue.

2 participants