-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fixed regression when registering two extensions with the same class #2200
Conversation
@fabpot With this diff applied, against
|
@@ -538,6 +559,21 @@ public function getName() | |||
} | |||
} | |||
|
|||
class Twig_Tests_EnvironmentTest_Extension_DynamicWithDeprecatedName extends Twig_Extension | |||
{ | |||
public $name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't need to be public, does it?
if (null !== $legacyName) { | ||
if (isset($this->legacyExtensions[$legacyName])) { | ||
unset($this->extensions[$class], $this->legacyExtensions[$legacyName]); | ||
@trigger_error(sprintf('The possibility to register the same extension twice ("%s") is deprecated since version 1.23 and will be removed in Twig 2.0. Use proper PHP inheritance instead.', $legacyName), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if $this->extensions[$class]
is set ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is now always set, we maintain two arrays in parallel. If you mean the same class once registered as a class and once as a legacy name, I don't think we need to support that.
@GawainLynch Can you tell me how I can reproduce this (I suppose you are having this with Bolt)? I have a blank page. And when I try to debug that, I have a problem not related to this one on your Twig filesystem loader, which breaks the contract of the original one as your override of |
Forgot to mention that when applying the patch on 2.6.1, I can use the Bolt interface without any issue. So, that's why I tried to use the latest version of Twig and found the issue mentioned above. |
Yeah, you're probably using < Bolt 3.2 … It's a long slow process to get the code base up to scratch, but the in the upcoming 3.2 (RC tomorrow) I ripped out the various attempts and exception handling and have switched us to
Yeah, we are hoping to engage with you on something around this in Twig 2. We abstract most of our file system, 3.3 should allow most mounts to be on services like S3, and as Twig internally assumes a local filesystem we had to make a choice there … To be continued. (ping @CarsonF)
I have created a couple of quick extensions repositories, to minimise code steps, and below (tested here) gets you up an running in core-developer mode (not recommended, obviously, for real use).
Load http://localhost:8080/ enter first user data, and you should be directed to the admin page. Click the link in the flash message "It seems there's no content in the database. To get started quickly, add some Lorem Ipsum dummy content." to create dummy content. Navigate to http://localhost:8080/bolt/file/edit/themes/base-2016/index.twig After line 5 add: {{ twig_a()|raw }}
{{ twig_b()|raw }} Save and visit http://localhost:8080/ Now update Twig to Note: I have separated this step out, as the Twig extensions breakage won't allow you to complete initial set-up Visit http://localhost:8080/ 💥 |
@GawainLynch Thank you so much. I can now reproduce the issue and I've a quick fix. I need to think a bit more about the final patch, but should be available today or tomorrow. |
9fd5495
to
767daf6
Compare
@GawainLynch Just pushed a new version. Can you check that it works well for you? |
@fabpot Fixed confirmed, thank you! Coffee is on me next time you're back in Europe. |
Thank you for helping me figure out this one, your reproducing steps helped a lot. |
fixed #2165