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

[TwigBundle] Fixing regression in TwigEngine exception handling#21179

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:2.7fromattila901:bugfix/twig-bundle/twig-engine/exception
Jan 10, 2017
Merged

[TwigBundle] Fixing regression in TwigEngine exception handling#21179

nicolas-grekas merged 1 commit intosymfony:2.7fromattila901:bugfix/twig-bundle/twig-engine/exception
Jan 10, 2017

Conversation

@attila901
Copy link

@attila901attila901 commentedJan 6, 2017
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#21176
LicenseMIT

Fixing regression after#20831 in TwigEngine exception handling.

}else {
$templateName =$e->getTemplateName();
}
$path = (string)$this->locator->locate($this->parser->parse($templateName));

Choose a reason for hiding this comment

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

the variable $name should be kept

Copy link
Author

Choose a reason for hiding this comment

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

But $name is a parameter that is already in use, and we even checking if$name instanceof TemplateReference. Should we overwrite this variable?

Copy link
Member

@nicolas-grekasnicolas-grekasJan 6, 2017
edited
Loading

Choose a reason for hiding this comment

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

if you want to rename it, you must rename also line 84 now

Copy link
Author

Choose a reason for hiding this comment

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

True, sorry I missed that part, fixed.

@nicolas-grekasnicolas-grekas changed the titleFixing regression in TwigEngine exception handling.[TwigBundle] Fixing regression in TwigEngine exception handlingJan 6, 2017
@nicolas-grekasnicolas-grekas added this to the2.7 milestoneJan 6, 2017
@nicolas-grekas
Copy link
Member

👍

$name =$e->getTemplateName();
$path = (string)$this->locator->locate($this->parser->parse($name));
if (method_exists($e,'getSourceContext')) {
$templateName =$e->getSourceContext()->getName();

Choose a reason for hiding this comment

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

@nicolas-grekas@attila901 maybe$path could be also get from the context with$e->getSourceContext()->getPath() in the else$path could be set the old way.

nicolas-grekas, attila901, nullziu, and chalasr reacted with thumbs up emoji
Copy link
Author

Choose a reason for hiding this comment

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

Thank you@burci , I've fixed.

burci reacted with thumbs up emoji
}
if (method_exists($e,'setSourceContext')) {
$e->setSourceContext(new \Twig_Source('',$name,$path));
$e->setSourceContext(new \Twig_Source('',$templateName,$path));
Copy link
Member

Choose a reason for hiding this comment

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

why not using$e->getSourceContext() directly here, instead of creating a new one with the same info ? Existence of the getter and setter go together (they have been introduced together)

Choose a reason for hiding this comment

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

After this@attila901 will end up something like this:

if (method_exists($e,'setSourceContext')) {$e->setSourceContext($e->getSourceContext());}else {$templateName =$e->getTemplateName();$path = (string)$this->locator->locate($this->parser->parse($templateName));$e->setTemplateName($path);}

The$e->setSourceContext($e->getSourceContext()); part can be skiped and we are not using the$name variable at all. Maybe after introducingsetSourceContext/getSourceContext it is always filled or we should get necessary info based on$name?

Copy link
Author

Choose a reason for hiding this comment

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

I've fixed.

$path = (string)$this->locator->locate($this->parser->parse($name));
if (method_exists($e,'setSourceContext')) {
$e->setSourceContext(new \Twig_Source('',$name,$path));
$e->setSourceContext($e->getSourceContext());
Copy link
Member

Choose a reason for hiding this comment

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

even better: do nothing in this case, as it is a no-op now

mdzzohrabi reacted with thumbs up emoji
@nicolas-grekas
Copy link
Member

Thank you@attila901.

@nicolas-grekasnicolas-grekas merged commit390cb33 intosymfony:2.7Jan 10, 2017
nicolas-grekas added a commit that referenced this pull requestJan 10, 2017
…dling (Bertalan Attila)This PR was merged into the 2.7 branch.Discussion----------[TwigBundle] Fixing regression in TwigEngine exception handling| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#21176| License       | MITFixing regression after#20831 in TwigEngine exception handling.Commits-------390cb33 Fixing regression in TwigEngine exception handling.
This was referencedJan 12, 2017
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

+1 more reviewer

@burciburciburci left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

5 participants

@attila901@nicolas-grekas@stof@burci@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp