-
Notifications
You must be signed in to change notification settings - Fork 191
Fix twig runtime extension last modification time detection #405
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
Conversation
stof
left a comment
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.
MenuRuntimeExtension was not marked as @internal and projects using the library have to handle instantiating it, so this PR is a BC break.
Please provide a custom implementation of getLastModified instead to achieve it without BC break.
src/Knp/Menu/Twig/MenuExtension.php
Outdated
| { | ||
| return max( | ||
| (int) filemtime(__FILE__), | ||
| (int) filemtime((string) (new \ReflectionClass(MenuRuntimeExtension::class))->getFileName()), |
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.
Casts added to keep Phpstan happy.
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.
We could simplify this by not using reflection but using __DIR__ . '/MenuRuntimeExtension.php') instead.
garak
left a comment
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.
Can we add a test?
This PR renames Twig runtime extension fromMenuRuntimeExtension.phptoMenuRuntime.phpto follow naming convention.This allows Twig to know when to recompile template(s) if extension code has changed.
This should not break BC because it is internal class not used anywhere else directly (correct me if I'm wrong).
This PR provides custom
MenuExtension::getLastModifiedmethod implementation. This allows Twig to know when to recompile template(s) if extension code has changed.