Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[TwigBridge] generate conflict-free variable names#59059

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
xabbuh merged 1 commit intosymfony:7.2fromxabbuh:twig-4480
Dec 2, 2024

Conversation

xabbuh
Copy link
Member

QA
Branch?7.2
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix#58706 (comment),FixEasyCorp/EasyAdminBundle#6605,Fixtwigphp/Twig#4480
LicenseMIT

@carsonbotcarsonbot added this to the7.2 milestoneDec 2, 2024
@carsonbotcarsonbot changed the title[TwigBridge] generate conflict-free variable names[TwigBridge] generate conflict-free variable namesDec 2, 2024
Copy link
Contributor

@pan93412pan93412 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

thank you!

private Scope $scope;
private int $nestingLevel = 0;
private int $nameCounter = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Having a global name counter will not produce reproducible builds (as it depends on the order of compilation of templates). And it does not even prevent conflicts in case the parent template was already cached from a previous compilation (and so not taking into account by the current counter).
There's a good reason why I previously suggested hashing the template name.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I changed the implementation back to what I initially had in#58706. But my question from#58706 (comment) still stands. How do we handle cases where there is no template name? Is using the counter (as I did for now) the way to go?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

AFAICT, this case cannot happen in a node visitor for traversed nodes. The parser sets the source context in the node during parsing, which sets it recursively in the whole tree. And from that point, setting a child node in a node of the tree will inject the source context in the child node.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What would you suggest? Remove the counter and do nothing? Or throw a runtime exception when that happens?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I suggest throwing a LogicException to be able to become aware of this unsupported state, in case it turns out it is not an impossible state. For now, I'm sure we would never reach this exception in practice during a template compilation.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

okay, I have updated the code accordingly

Copy link
Member

@javiereguiluzjaviereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

These changes fixed the reported issue for me. Thanks!

@xabbuhxabbuh merged commitcc1802d intosymfony:7.2Dec 2, 2024
10 checks passed
@xabbuhxabbuh deleted the twig-4480 branchDecember 2, 2024 12:43
javiereguiluz added a commit to EasyCorp/EasyAdminBundle that referenced this pull requestDec 3, 2024
…luz)This PR was squashed before being merged into the 4.x branch.Discussion----------Temporary ignore errors in Symfony 7.2 branchEasyAdmin won't work with Symfony 7.2 until this bugfix:symfony/symfony#59059 is not released in Symfony 7.2.1.So, ignore errors (temporarily) in Symfony 7.2.Commits-------5731774 Temporary ignore errors in Symfony 7.2 branch
nicolas-grekas added a commit that referenced this pull requestDec 7, 2024
…ith dynamic expressions (stof)This PR was merged into the 6.4 branch.Discussion----------[TwigBridge] Add tests covering `trans_default_domain` with dynamic expressions| Q             | A| ------------- | ---| Branch?       | 6.4| Bug fix?      | no| New feature?  | no| Deprecations? | no| Issues        || License       | MITThis adds tests covering the usage of `{% trans_default_domain %}` with dynamic expressions (which we broken in 7.2.0 and fixed in#59059, which those tests would have caught).I'm adding those tests in 6.4 to increase test coverage on all versions, given that the test does not require changes anyway when upmerging.#SymfonyHackdayCommits-------6262a62 Add tests covering `trans_default_domain` with dynamic expressions
@fabpotfabpot mentioned this pull requestDec 11, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dunglasdunglasdunglas approved these changes

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

@stofstofstof approved these changes

@pan93412pan93412pan93412 approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
7.2
Development

Successfully merging this pull request may close these issues.

6 participants
@xabbuh@dunglas@javiereguiluz@stof@pan93412@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp