Skip to content

[TwigComponent][LiveComponent] Fix Live embedded component within namespaced template #1082

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

Conversation

sneakyvv
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
Tickets
License MIT

This fix is related to #1070 .
That PR made sure that a namespaced template could also be found in the TemplateMap, which contains paths without the namespace, so that the right template name (or actually obscuring hash) is used for the host template reference for live embedded components within such a template (which is used to find the right blocks during a re-render).

However, because the Parser was still using the namespaced template name to calculate the deterministic index number for an embedded template, it would not match with the index of the stripped / namespace-less template name, causing it to have a different index for the embedded template during re-render then during parsing, resulting in a template not found error.

This PR now also strips namespaces from template names during parsing.

@sneakyvv sneakyvv force-pushed the fix-embedded-live-component-with-namespace branch from 5ae1982 to ad84cf7 Compare August 30, 2023 10:41
@sneakyvv sneakyvv changed the title [TwigComponent] Fix Live embedded component within namespaced template [TwigComponent][LiveComponent] Fix Live embedded component within namespaced template Aug 30, 2023
@weaverryan
Copy link
Member

Fantastic - thank you for the fix and the test!

@weaverryan weaverryan merged commit 9a8f599 into symfony:2.x Aug 30, 2023
@sneakyvv sneakyvv deleted the fix-embedded-live-component-with-namespace branch August 30, 2023 19:16
smnandre added a commit to smnandre/ux that referenced this pull request Apr 23, 2024
I believe this modification fix issue symfony#1754

**Original problem**

If you render a template @Acme/dashboard.html.twig, embedded Components (live or twig) referenced wrong template (dashboard.html.twig here), making LiveComponent impossible to rerender (this file beeing not referenced in the TemplateMap).

This behaviour was introduced in symfony#1082 (and worked then). But i'm convinced all the work/changes made by Ryan to fix the embed bug (symfony#1247 and related) made this obselete (and in this particular situation even originates a bug)

All tests are green, and i'd like to test it more heavily... but before that : do you think this is a bug fix or is there some kind of BC break here?
smnandre added a commit to smnandre/ux that referenced this pull request Apr 24, 2024
I believe this modification fix issue symfony#1754

**Original problem**

If you render a template @Acme/dashboard.html.twig, embedded Components (live or twig) referenced wrong template (dashboard.html.twig here), making LiveComponent impossible to rerender (this file beeing not referenced in the TemplateMap).

This behaviour was introduced in symfony#1082 (and worked then). But i'm convinced all the work/changes made by Ryan to fix the embed bug (symfony#1247 and related) made this obselete (and in this particular situation even originates a bug)

All tests are green, and i'd like to test it more heavily... but before that : do you think this is a bug fix or is there some kind of BC break here?
kbond added a commit that referenced this pull request Apr 25, 2024
This PR was squashed before being merged into the 2.x branch.

Discussion
----------

[TwigComponent] Fix LiveComponent namespace mapping

I believe this modification fix #1754

**Original problem**

If you render a template `@Acme`/dashboard.html.twig, embedded Components (live or twig) referenced wrong template (dashboard.html.twig here), making LiveComponent impossible to rerender (this file beeing not referenced in the TemplateMap).

This behaviour was introduced in #1082 (and worked then). But i'm convinced all the work/changes made by Ryan to fix the embed bug (#1247 and related) made this obselete (and in this particular situation even originates a bug)

All tests are green, and i'd like to test it more heavily... but before that : do you think this is a bug fix or is there some kind of BC break here?

Commits
-------

bb76055 [TwigComponent] Fix LiveComponent namespace mapping
smnandre added a commit that referenced this pull request Jan 25, 2025
…yvv)

This PR was merged into the 2.x branch.

Discussion
----------

[TwigComponent] Remove obsolete TemplateNameParser

It no longer parses (and should not have been stripping namespaces as it did before)

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| Issues        |
| License       | MIT

As discussed in #1772 (comment), the code added in #1070 (& expanded in #1082) was not needed (even incorrect, based upon a decorator TemplateIterator of Shopware).

Commits
-------

99cb909 Remove obsolete TemplateNameParser
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.

2 participants