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] use reproducible variable names in the default domain node visitor#58706

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
nicolas-grekas merged 1 commit intosymfony:7.2fromxabbuh:pr-57609
Nov 6, 2024

Conversation

xabbuh
Copy link
Member

QA
Branch?7.2
Bug fix?no
New feature?yes
Deprecations?no
IssuesFix#57609 (comment)
LicenseMIT

return new SetNode(false, new Nodes([$name]), new Nodes([$node->getNode('expr')]), $node->getTemplateLine());
}

$var = '__internal_trans_default_domain';

if (null !== $templateName = $node->getTemplateName()) {
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I wonder what we do when there is no template name? We could use an internal counter in this visitor and append it to the prefix instead maybe?

Choose a reason for hiding this comment

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

if a counter can replace any hashing, then yes, that'd be nicer

return new SetNode(false, new Nodes([$name]), new Nodes([$node->getNode('expr')]), $node->getTemplateLine());
}

$var = '__internal_trans_default_domain_'.$this->nestingLevel;

Choose a reason for hiding this comment

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

I updated the implementation to rely on a counter instead

Copy link
Member

Choose a reason for hiding this comment

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

@nicolas-grekas using a counter for the nesting level inside the current template doesnot solve the issue that this PR tries to fix, meaning that my comment in#57609 (comment) isnot solved and that Symfony 7.2 still breaks the case where both a parent template and its child template use{% trans_default_domain %}

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

FTR, this was fixed in#58706

@nicolas-grekasnicolas-grekas merged commit5557736 intosymfony:7.2Nov 6, 2024
10 checks passed
@nicolas-grekas
Copy link
Member

Thank you@xabbuh

@fabpotfabpot mentioned this pull requestNov 6, 2024
@xabbuhxabbuh deleted the pr-57609 branchNovember 6, 2024 10:04
if (class_exists(Nodes::class)) {
$name = new LocalVariable(null, $node->getTemplateLine());
Copy link
Member

Choose a reason for hiding this comment

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

@xabbuh changing this to a local variable is likely the root cause ofEasyCorp/EasyAdminBundle#6605 because a local variable will not be available in blocks (it won't stay available in the Twig child scopes that are totally separate PHP scopes in the compiled template).

To me, we should keep assigning a context variable, as done before your PR.

return new SetNode(false, new Nodes([$name]), new Nodes([$node->getNode('expr')]), $node->getTemplateLine());
}

$var = '__internal_trans_default_domain_'.$this->nestingLevel;
Copy link
Member

Choose a reason for hiding this comment

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

@nicolas-grekas using a counter for the nesting level inside the current template doesnot solve the issue that this PR tries to fix, meaning that my comment in#57609 (comment) isnot solved and that Symfony 7.2 still breaks the case where both a parent template and its child template use{% trans_default_domain %}

xabbuh added a commit that referenced this pull requestDec 2, 2024
This PR was merged into the 7.2 branch.Discussion----------[TwigBridge] generate conflict-free variable names| Q             | A| ------------- | ---| Branch?       | 7.2| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Issues        |Fix#58706 (comment),FixEasyCorp/EasyAdminBundle#6605,Fixtwigphp/Twig#4480| License       | MITCommits-------1a38aca generate conflict-free variable names
symfony-splitter pushed a commit to symfony/twig-bridge that referenced this pull requestDec 2, 2024
This PR was merged into the 7.2 branch.Discussion----------[TwigBridge] generate conflict-free variable names| Q             | A| ------------- | ---| Branch?       | 7.2| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Issues        |Fixsymfony/symfony#58706 (comment),FixEasyCorp/EasyAdminBundle#6605,Fixtwigphp/Twig#4480| License       | MITCommits-------1a38acac24 generate conflict-free variable names
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@stofstofstof left review comments

@alexandre-dauboisalexandre-dauboisalexandre-daubois approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
7.2
Development

Successfully merging this pull request may close these issues.

5 participants
@xabbuh@nicolas-grekas@stof@alexandre-daubois@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp